{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "撰写人：陈蕙兰  \n",
    "***\n",
    "# 高德API map功能应用  \n",
    "> * 地理编码  \n",
    "> * 逆地理编码  \n",
    "> * 路径规划  \n",
    "> * 行政区域查询  \n",
    "> * 搜索PIO  \n",
    "> * IP定位  \n",
    "> * 批量请求接口  \n",
    "> * 静态地图  \n",
    "> * 坐标转换  \n",
    "> * 天气查询  \n",
    "> * 输入提示  \n",
    "> * 交通态势  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 地理编码  \n",
    "* 1、url：https://restapi.amap.com/v3/geocode/geo?parameters  \n",
    "* 2、requests.get()\n",
    "* 3、参数：  \n",
    "    A.必选：key，address  \n",
    "    B.可选：city，batch（默认false），sig，output（默认JSON），callback"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 171,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests,json\n",
    "import pandas as pd\n",
    "chen_key = \"c170f884cb9aa6a378070c7af4907ab4\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 178,
   "metadata": {},
   "outputs": [],
   "source": [
    "def geo(key,address,city=None,batch=None):\n",
    "    \"\"\"获取高德API地理编码\n",
    "    通过 HTTP/HTTPS 协议访问远程服务的接口，提供结构化地址与经纬度之间的相互转化\"\"\"\n",
    "    url = \"https://restapi.amap.com/v3/geocode/geo?parameters\"\n",
    "    params = {\n",
    "        \"key\":key,\n",
    "        \"address\":address,\n",
    "        \"city\":city,\n",
    "        \"batch\":batch\n",
    "    }\n",
    "    response = requests.get(url,params=params)\n",
    "    results = response.json()['geocodes'][0]['location']\n",
    "    # 返回值\n",
    "    return results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 179,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.082300,22.617076'"
      ]
     },
     "execution_count": 179,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "myaddress = \"广东省江门市蓬江区广场西路\"\n",
    "location = geo(chen_key,myaddress)\n",
    "location"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 应用场景\n",
    "通过获取到的地理编码即经纬度在地图中标出用户查询的结构性地址的位置（点）"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 逆地理编码\n",
    "* 1、url：https://restapi.amap.com/v3/geocode/regeo?parameters  \n",
    "* 2、requests.get()  \n",
    "* 3、参数：  \n",
    "    A.必选：key，location  \n",
    "    B.可选：poitype，radius（默认：1000），extensions（默认：base），roadlevel，sig,output(默认JSON)，callback,homeorcorp(默认0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 187,
   "metadata": {},
   "outputs": [],
   "source": [
    "def regeo(key,location,poitype=None,radius=1000,extensions=\"base\",roadlevel=None,sig=None,output=\"JSON\",callback=None,homeorcorp=0):\n",
    "    \"\"\"获取逆地理编码\n",
    "    通过 HTTP/HTTPS 协议访问远程服务的接口，提供结构化地址与经纬度之间的相互转化\n",
    "    \"\"\"\n",
    "    url = \"https://restapi.amap.com/v3/geocode/regeo?parameters\"\n",
    "    params = {\n",
    "    \"key\":chen_key,\n",
    "    \"location\":location,\n",
    "    \"poitype\":poitype,\n",
    "    \"radius\":radius,\n",
    "    \"roadlevel\":roadlevel,\n",
    "    \"sig\":sig,\n",
    "    \"output\":output,\n",
    "    \"callback\":callback,\n",
    "    \"homeorcorp\":homeorcorp,\n",
    "    \"extensions\":\"all\"\n",
    "    }\n",
    "    r = requests.get(url,params)\n",
    "    results = r.json()['regeocode']\n",
    "    return results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 188,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'roads': [{'id': '0750F49F017041252',\n",
       "   'location': '113.082,22.6171',\n",
       "   'direction': '西',\n",
       "   'name': '广场西路',\n",
       "   'distance': '0.513241'},\n",
       "  {'id': '0750F49F017041246',\n",
       "   'location': '113.082,22.6155',\n",
       "   'direction': '北',\n",
       "   'name': '发展大道',\n",
       "   'distance': '172.731'},\n",
       "  {'id': '0750F49F0170419593',\n",
       "   'location': '113.086,22.6171',\n",
       "   'direction': '西',\n",
       "   'name': '广场东路',\n",
       "   'distance': '405.325'}],\n",
       " 'roadinters': [{'second_name': '广场西路',\n",
       "   'first_id': '0750F49F017041246',\n",
       "   'second_id': '0750F49F017041252',\n",
       "   'location': '113.082240,22.615319',\n",
       "   'distance': '195.5',\n",
       "   'first_name': '发展大道',\n",
       "   'direction': '北'}],\n",
       " 'formatted_address': '广东省江门市蓬江区环市街道广场西路江门万达广场',\n",
       " 'addressComponent': {'city': '江门市',\n",
       "  'province': '广东省',\n",
       "  'adcode': '440703',\n",
       "  'district': '蓬江区',\n",
       "  'towncode': '440703006000',\n",
       "  'streetNumber': {'number': '200号',\n",
       "   'location': '113.082317,22.617126',\n",
       "   'direction': '北',\n",
       "   'distance': '5.8257',\n",
       "   'street': '发展大道'},\n",
       "  'country': '中国',\n",
       "  'township': '环市街道',\n",
       "  'businessAreas': [[]],\n",
       "  'building': {'name': [], 'type': []},\n",
       "  'neighborhood': {'name': [], 'type': []},\n",
       "  'citycode': '0750'},\n",
       " 'aois': [{'area': '90860.329620',\n",
       "   'type': '060101',\n",
       "   'id': 'B02EE0PZEK',\n",
       "   'location': '113.084649,22.618256',\n",
       "   'adcode': '440703',\n",
       "   'name': '江门万达广场',\n",
       "   'distance': '9.80939'},\n",
       "  {'area': '67619.966939',\n",
       "   'type': '100102',\n",
       "   'id': 'B02EE027WZ',\n",
       "   'location': '113.080390,22.616696',\n",
       "   'adcode': '440703',\n",
       "   'name': '名冠金凯悦酒店',\n",
       "   'distance': '16.9974'}],\n",
       " 'pois': [{'id': 'B02EE0PZEK',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '广场西路',\n",
       "   'poiweight': '0.508736',\n",
       "   'name': '江门万达广场',\n",
       "   'location': '113.084649,22.618256',\n",
       "   'distance': '274.501',\n",
       "   'tel': '0750-2088333;0750-3981016',\n",
       "   'type': '购物服务;商场;购物中心'},\n",
       "  {'id': 'B02EE027X0',\n",
       "   'direction': '西南',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道188号金凯悦酒店1-2层',\n",
       "   'poiweight': '0.48',\n",
       "   'name': '中信银行(江门北新支行)',\n",
       "   'location': '113.081281,22.616279',\n",
       "   'distance': '137.104',\n",
       "   'tel': '0750-3939399',\n",
       "   'type': '金融保险服务;银行;中信银行'},\n",
       "  {'id': 'B0FFHCI589',\n",
       "   'direction': '东',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道万达广场2层2022',\n",
       "   'poiweight': '0.149041',\n",
       "   'name': '美联英语(蓬江万达中心)',\n",
       "   'location': '113.083112,22.617330',\n",
       "   'distance': '87.9965',\n",
       "   'tel': '4007001003',\n",
       "   'type': '科教文化服务;培训机构;培训机构'},\n",
       "  {'id': 'B0FFFRCRS6',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '环市街道万达广场甲级写字楼1幢39层',\n",
       "   'poiweight': '0.223068',\n",
       "   'name': '万达百货',\n",
       "   'location': '113.083084,22.617490',\n",
       "   'distance': '92.6974',\n",
       "   'tel': [],\n",
       "   'type': '购物服务;商场;普通商场'},\n",
       "  {'id': 'B0FFFKXBC8',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道江门万达广场15栋负1楼超市',\n",
       "   'poiweight': '0.455282',\n",
       "   'name': '华润万家(发展大道店)',\n",
       "   'location': '113.083088,22.617968',\n",
       "   'distance': '127.989',\n",
       "   'tel': '0750-3699111',\n",
       "   'type': '购物服务;超级市场;华润'},\n",
       "  {'id': 'B0FFGDFY4Q',\n",
       "   'direction': '东',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道',\n",
       "   'poiweight': '0.275375',\n",
       "   'name': '万达中心写字楼1幢',\n",
       "   'location': '113.083701,22.617323',\n",
       "   'distance': '146.42',\n",
       "   'tel': [],\n",
       "   'type': '地名地址信息;门牌信息;楼栋号'},\n",
       "  {'id': 'B0FFFWSLM4',\n",
       "   'direction': '北',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道万达广场14层',\n",
       "   'poiweight': '0.32712',\n",
       "   'name': '2513服务公寓(江门万达店)',\n",
       "   'location': '113.082687,22.618535',\n",
       "   'distance': '167.02',\n",
       "   'tel': '13392513918',\n",
       "   'type': '住宿服务;宾馆酒店;宾馆酒店'},\n",
       "  {'id': 'B0FFHUNPLF',\n",
       "   'direction': '东',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道江门万达广场二层',\n",
       "   'poiweight': '0.274091',\n",
       "   'name': '屈臣氏',\n",
       "   'location': '113.083826,22.617310',\n",
       "   'distance': '158.797',\n",
       "   'tel': '0750-3716127;4008301310',\n",
       "   'type': '购物服务;超级市场;屈臣氏'},\n",
       "  {'id': 'B0FFFRCLMY',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '广场西路江门万达广场1号门1层',\n",
       "   'poiweight': '0.416158',\n",
       "   'name': '肯德基(江门万达广场)',\n",
       "   'location': '113.082867,22.617350',\n",
       "   'distance': '65.6837',\n",
       "   'tel': '0750-3716179;4009200715',\n",
       "   'type': '餐饮服务;快餐厅;肯德基'},\n",
       "  {'id': 'B0FFFKWXTM',\n",
       "   'direction': '东',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道万达广场1026及2039A商铺',\n",
       "   'poiweight': '0.228599',\n",
       "   'name': '必胜客(江门万达店)',\n",
       "   'location': '113.082910,22.617044',\n",
       "   'distance': '62.7179',\n",
       "   'tel': '0750-3339500;4009208809;0750-3339100',\n",
       "   'type': '餐饮服务;快餐厅;必胜客'},\n",
       "  {'id': 'B0FFHUNPKF',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道江门万达广场15幢1-2层1001A号',\n",
       "   'poiweight': '0.306346',\n",
       "   'name': '麦当劳(江门万达广场店)',\n",
       "   'location': '113.083084,22.617490',\n",
       "   'distance': '92.6974',\n",
       "   'tel': '0750-3719290',\n",
       "   'type': '餐饮服务;快餐厅;麦当劳'},\n",
       "  {'id': 'B0FFG7UUA5',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道万达购物中心2号门16栋1408室',\n",
       "   'poiweight': '0.279752',\n",
       "   'name': '啪啪爱公寓酒店(江门万达店)',\n",
       "   'location': '113.083201,22.618635',\n",
       "   'distance': '196.482',\n",
       "   'tel': [],\n",
       "   'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
       "  {'id': 'B0FFFKWU10',\n",
       "   'direction': '东',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道以北八卦山以南地段万达广场首层1024A-1025B',\n",
       "   'poiweight': '0.107979',\n",
       "   'name': '星巴克(江门万达广场店)',\n",
       "   'location': '113.083487,22.617059',\n",
       "   'distance': '121.853',\n",
       "   'tel': '0750-3719150',\n",
       "   'type': '餐饮服务;咖啡厅;星巴克咖啡'},\n",
       "  {'id': 'B0FFFT80SN',\n",
       "   'direction': '北',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道与广场交汇处万达广场2楼',\n",
       "   'poiweight': '0.183936',\n",
       "   'name': '尚品宅配(万达广场店)',\n",
       "   'location': '113.082956,22.618747',\n",
       "   'distance': '197.626',\n",
       "   'tel': '13125224688',\n",
       "   'type': '购物服务;家居建材市场;家具城'},\n",
       "  {'id': 'B0FFIW4FM3',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '江门万达广场15幢3FA-01之1',\n",
       "   'poiweight': '0.157063',\n",
       "   'name': '美吉姆(江门万达中心)',\n",
       "   'location': '113.083029,22.617617',\n",
       "   'distance': '95.9937',\n",
       "   'tel': '0750-3911988;18666990962',\n",
       "   'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
       "  {'id': 'B0FFH19XDZ',\n",
       "   'direction': '北',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道江门万达广场15栋F3-02',\n",
       "   'poiweight': '0.159951',\n",
       "   'name': '靓家居(江门万达店)',\n",
       "   'location': '113.082480,22.617926',\n",
       "   'distance': '96.309',\n",
       "   'tel': '0750-3910703',\n",
       "   'type': '购物服务;家居建材市场;家具城'},\n",
       "  {'id': 'B0FFIGLVJE',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '广场西路江门万达广场3F层',\n",
       "   'poiweight': '0.172998',\n",
       "   'name': '靓家居·家服务中心(江门万达广场)',\n",
       "   'location': '113.083109,22.617590',\n",
       "   'distance': '100.795',\n",
       "   'tel': [],\n",
       "   'type': '购物服务;家居建材市场;家居建材市场'},\n",
       "  {'id': 'B0FFH1NQOQ',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '广场东路五邑华侨广场对面江门万达购物广场2楼(麦当劳旁)',\n",
       "   'poiweight': '0.188066',\n",
       "   'name': '苏宁易购(江门万达广场店)',\n",
       "   'location': '113.083033,22.617754',\n",
       "   'distance': '106.501',\n",
       "   'tel': '0750-3466778;13427239557',\n",
       "   'type': '购物服务;家电电子卖场;苏宁'},\n",
       "  {'id': 'B0FFLC5L2D',\n",
       "   'direction': '东',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道江门万达广场1层1025B',\n",
       "   'poiweight': '0.171966',\n",
       "   'name': '哈根达斯(万达店)',\n",
       "   'location': '113.083387,22.617038',\n",
       "   'distance': '111.653',\n",
       "   'tel': '0750-3699011;4009870870',\n",
       "   'type': '餐饮服务;冷饮店;冷饮店'},\n",
       "  {'id': 'B0FFHUNPLY',\n",
       "   'direction': '东',\n",
       "   'businessarea': [],\n",
       "   'address': '广场西路江门万达广场2F层2022',\n",
       "   'poiweight': '0.149673',\n",
       "   'name': '美联英语(江门万达广场)',\n",
       "   'location': '113.083366,22.617072',\n",
       "   'distance': '109.435',\n",
       "   'tel': [],\n",
       "   'type': '科教文化服务;培训机构;培训机构'},\n",
       "  {'id': 'B0FFG6G0B2',\n",
       "   'direction': '东',\n",
       "   'businessarea': [],\n",
       "   'address': '江门万达广场五邑老街入口对面',\n",
       "   'poiweight': '0.205449',\n",
       "   'name': '老广新意(江门万达广场店)',\n",
       "   'location': '113.082873,22.617302',\n",
       "   'distance': '63.9594',\n",
       "   'tel': '0750-3101818',\n",
       "   'type': '餐饮服务;中餐厅;广东菜(粤菜)'},\n",
       "  {'id': 'B0FFL2JC0F',\n",
       "   'direction': '东',\n",
       "   'businessarea': [],\n",
       "   'address': '广场西路江门万达广场3F层',\n",
       "   'poiweight': '0.154919',\n",
       "   'name': '米娜凯威国际礼仪艺术教育(江门万达广场)',\n",
       "   'location': '113.083453,22.617088',\n",
       "   'distance': '118.367',\n",
       "   'tel': '0750-3919568',\n",
       "   'type': '科教文化服务;培训机构;培训机构'},\n",
       "  {'id': 'B0FFLC5L3S',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '广场西路江门万达广场3F层',\n",
       "   'poiweight': '0.147132',\n",
       "   'name': '美吉姆国际儿童教育中心(江门万达广场)',\n",
       "   'location': '113.083344,22.617578',\n",
       "   'distance': '120.819',\n",
       "   'tel': [],\n",
       "   'type': '科教文化服务;培训机构;培训机构'},\n",
       "  {'id': 'B0FFHUNPLI',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '江门万达广场15幢3FA-01万达3层',\n",
       "   'poiweight': '0.149673',\n",
       "   'name': '美吉姆国际儿童教育中心早教江门万达中心',\n",
       "   'location': '113.082832,22.618110',\n",
       "   'distance': '127.276',\n",
       "   'tel': '0750-3911988',\n",
       "   'type': '商务住宅;商务住宅相关;商务住宅相关'},\n",
       "  {'id': 'B0FFLC5L3W',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道万达广场5楼(名冠酒店对面)',\n",
       "   'poiweight': '0.209618',\n",
       "   'name': '澳莱酷品牛扒(江门万达广场店)',\n",
       "   'location': '113.082861,22.617663',\n",
       "   'distance': '87.048',\n",
       "   'tel': '0750-3690999',\n",
       "   'type': '餐饮服务;外国餐厅;西餐厅(综合风味)'},\n",
       "  {'id': 'B0FFIVVRZX',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '广场西路江门万达广场3F层',\n",
       "   'poiweight': '0.15017',\n",
       "   'name': '企鹅家族英语(江门万达广场)',\n",
       "   'location': '113.083360,22.617871',\n",
       "   'distance': '140.193',\n",
       "   'tel': '0750-3906388;13923080068',\n",
       "   'type': '科教文化服务;培训机构;培训机构'},\n",
       "  {'id': 'B0FFH1U2A3',\n",
       "   'direction': '东',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道北100米',\n",
       "   'poiweight': '0.195789',\n",
       "   'name': '万达中心A座',\n",
       "   'location': '113.083675,22.617003',\n",
       "   'distance': '141.375',\n",
       "   'tel': [],\n",
       "   'type': '商务住宅;楼宇;商务写字楼'},\n",
       "  {'id': 'B0FFLC5L3O',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '广场西路江门万达广场3F层',\n",
       "   'poiweight': '0.147132',\n",
       "   'name': '汇彤教育(江门万达广场)',\n",
       "   'location': '113.083682,22.617815',\n",
       "   'distance': '163.931',\n",
       "   'tel': [],\n",
       "   'type': '科教文化服务;培训机构;培训机构'},\n",
       "  {'id': 'B0FFGC21XQ',\n",
       "   'direction': '东北',\n",
       "   'businessarea': [],\n",
       "   'address': '环市街道发展大道江门万达广场15幢3楼地下停车场E层右边直行50米电梯直上三楼',\n",
       "   'poiweight': '0.205887',\n",
       "   'name': '客语·客家菜(江门万达店)',\n",
       "   'location': '113.082866,22.617340',\n",
       "   'distance': '65.0991',\n",
       "   'tel': '0750-3699060',\n",
       "   'type': '餐饮服务;中餐厅;中餐厅'},\n",
       "  {'id': 'B0FFGC3HF9',\n",
       "   'direction': '东',\n",
       "   'businessarea': [],\n",
       "   'address': '发展大道江门万达广场F1',\n",
       "   'poiweight': '0.206075',\n",
       "   'name': '濑子杂酱面',\n",
       "   'location': '113.083923,22.617568',\n",
       "   'distance': '175.355',\n",
       "   'tel': '15629887920;18922024991',\n",
       "   'type': '餐饮服务;中餐厅;中餐厅'}]}"
      ]
     },
     "execution_count": 188,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "address = regeo(chen_key,location)\n",
    "address"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 应用场景\n",
    "以地理坐标可以转化出结构化地址及地址元素列表、poi信息列表，可以用于地图中查询坐标附近的学校、商圈、医院等功能服务"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 路径规划\n",
    "### 步行\n",
    "* 1、url：https://restapi.amap.com/v3/direction/walking?parameters\n",
    "* 2、requests.get()\n",
    "* 3、参数：  \n",
    "    A.必选：key，origin，destination  \n",
    "    B.可选：sig,output(默认JSON),callback  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 195,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.679287,23.632575'"
      ]
     },
     "execution_count": 195,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#数据准备\n",
    "myorigin = \"广东省广州市从化区中山大学南方学院\"\n",
    "mydestination = \"广东省广州市从化区温泉镇温泉山庄\"\n",
    "起始点 = geo(chen_key,myorigin)\n",
    "起始点"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 196,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.655442,23.641986'"
      ]
     },
     "execution_count": 196,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "目的地 = geo(chen_key,mydestination)\n",
    "目的地"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 200,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "#步行\n",
    "def walk(key,origin,destination,sig=None,output=\"JSON\",callback=None):\n",
    "    \"\"\"获取步行路径规划\n",
    "    可以规划100KM以内的步行通勤方案，并且返回通勤方案的数据。\"\"\"\n",
    "    url = \"https://restapi.amap.com/v3/direction/walking?parameters\"\n",
    "    params = {\n",
    "    \"key\":key,\n",
    "    \"origin\":origin,\n",
    "    \"destination\":destination,\n",
    "    \"sig\":sig,\n",
    "    \"output\":output,\n",
    "    \"callback\":callback\n",
    "    }\n",
    "    r = requests.get(url,params)\n",
    "    results = r.json()['route']['paths'][0]['steps']\n",
    "    return results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 201,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'instruction': '向东步行101米右转',\n",
       "  'orientation': '东',\n",
       "  'road': [],\n",
       "  'distance': '101',\n",
       "  'duration': '81',\n",
       "  'polyline': '113.679592,23.632491;113.680586,23.632522',\n",
       "  'action': '右转',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '向南步行199米向右前方行走',\n",
       "  'orientation': '南',\n",
       "  'road': [],\n",
       "  'distance': '199',\n",
       "  'duration': '159',\n",
       "  'polyline': '113.680586,23.632522;113.680638,23.63214;113.680668,23.63174;113.680634,23.631541;113.68059,23.631437;113.68059,23.631437;113.680499,23.631241;113.680408,23.631094;113.680208,23.630842',\n",
       "  'action': '向右前方行走',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '向西步行159米左转',\n",
       "  'orientation': '西',\n",
       "  'road': [],\n",
       "  'distance': '159',\n",
       "  'duration': '127',\n",
       "  'polyline': '113.680204,23.630838;113.680035,23.630773;113.680035,23.630773;113.679644,23.630638;113.679644,23.630638;113.679362,23.630521;113.679201,23.630473;113.679201,23.630473;113.679032,23.63043;113.679032,23.63043;113.67888,23.630404;113.67888,23.630404;113.678711,23.630365',\n",
       "  'action': '左转',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '向南步行237米左转',\n",
       "  'orientation': '南',\n",
       "  'road': [],\n",
       "  'distance': '237',\n",
       "  'duration': '190',\n",
       "  'polyline': '113.678711,23.63036;113.678711,23.62934;113.678711,23.62934;113.678711,23.629193;113.678689,23.629084;113.678637,23.629023;113.678424,23.628902;113.678368,23.628841;113.678316,23.628724;113.678294,23.628611;113.678294,23.628611;113.678277,23.628372',\n",
       "  'action': '左转',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '向南步行498米向右前方行走',\n",
       "  'orientation': '南',\n",
       "  'road': [],\n",
       "  'distance': '498',\n",
       "  'duration': '398',\n",
       "  'polyline': '113.678273,23.628368;113.678572,23.628338;113.678685,23.628307;113.678685,23.628307;113.678845,23.628234;113.679045,23.628073;113.679158,23.627964;113.679158,23.627964;113.679214,23.627869;113.679236,23.627778;113.67928,23.627526;113.679288,23.627322;113.679288,23.627322;113.679253,23.626853;113.679184,23.626623;113.679141,23.626497;113.679002,23.626259;113.678941,23.626176;113.678711,23.625977;113.67862,23.625864;113.678529,23.62572;113.678438,23.625191;113.678429,23.625056;113.678451,23.624939;113.678572,23.624657',\n",
       "  'action': '向右前方行走',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '沿源富街向西南步行1568米直行',\n",
       "  'orientation': '西南',\n",
       "  'road': '源富街',\n",
       "  'distance': '1568',\n",
       "  'duration': '1254',\n",
       "  'polyline': '113.678572,23.624653;113.678559,23.62451;113.678416,23.624323;113.678416,23.624323;113.677582,23.623793;113.676532,23.623346;113.676363,23.623255;113.676272,23.623151;113.676111,23.622834;113.676042,23.622739;113.67579,23.622483;113.675499,23.622279;113.675417,23.622174;113.675386,23.622088;113.675378,23.621836;113.675378,23.621836;113.675391,23.62161;113.675434,23.621476;113.675543,23.621359;113.675764,23.621181;113.675846,23.621089;113.675903,23.620994;113.675907,23.620855;113.675877,23.620725;113.675747,23.620547;113.675599,23.620373;113.675243,23.620013;113.675243,23.620013;113.674935,23.619718;113.673924,23.618624;113.673694,23.618433;113.673464,23.618338;113.67322,23.618277;113.671085,23.617791;113.671085,23.617791;113.667904,23.617101',\n",
       "  'action': '直行',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '沿源湖街向西步行783米右转',\n",
       "  'orientation': '西',\n",
       "  'road': '源湖街',\n",
       "  'distance': '783',\n",
       "  'duration': '626',\n",
       "  'polyline': '113.667899,23.617096;113.666345,23.61674;113.666345,23.61674;113.66592,23.616654;113.66592,23.616654;113.663585,23.616133;113.663585,23.616133;113.663516,23.616111;113.663516,23.616111;113.663225,23.616046;113.663225,23.616046;113.662578,23.615916;113.662578,23.615916;113.662036,23.615807;113.661693,23.615716;113.661693,23.615716;113.660404,23.615421',\n",
       "  'action': '右转',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '沿龙泉路向西北步行1722米右转',\n",
       "  'orientation': '西北',\n",
       "  'road': '龙泉路',\n",
       "  'distance': '1722',\n",
       "  'duration': '1378',\n",
       "  'polyline': '113.660399,23.615417;113.66,23.615668;113.66,23.615668;113.659089,23.616233;113.657166,23.617487;113.656984,23.617626;113.656719,23.617891;113.656719,23.617891;113.655833,23.618845;113.655686,23.618971;113.655543,23.619076;113.655421,23.619141;113.655282,23.619188;113.655087,23.619236;113.654748,23.619297;113.654514,23.619306;113.654514,23.619306;113.654332,23.619306;113.653971,23.619249;113.652895,23.619015;113.652726,23.618989;113.652574,23.618989;113.652431,23.619015;113.651819,23.61924;113.651819,23.61924;113.65082,23.619614;113.649362,23.619948;113.649362,23.619948;113.648819,23.620078;113.648355,23.620221;113.64809,23.620313;113.647869,23.620438;113.647869,23.620438;113.647378,23.620781;113.647188,23.620894;113.646966,23.620994;113.64648,23.621176;113.646328,23.621259;113.645877,23.621567;113.645877,23.621567;113.645725,23.621697',\n",
       "  'action': '右转',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '沿龙泉路向北步行45米向右前方行走',\n",
       "  'orientation': '北',\n",
       "  'road': '龙泉路',\n",
       "  'distance': '45',\n",
       "  'duration': '36',\n",
       "  'polyline': '113.64572,23.621697;113.645725,23.621875;113.64582,23.622088',\n",
       "  'action': '向右前方行走',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '沿温泉大道向东北步行263米',\n",
       "  'orientation': '东北',\n",
       "  'road': '温泉大道',\n",
       "  'distance': '263',\n",
       "  'duration': '210',\n",
       "  'polyline': '113.64582,23.622088;113.646254,23.622283;113.646636,23.622496;113.647222,23.622856;113.647695,23.623177;113.647695,23.623177;113.647977,23.62339',\n",
       "  'action': [],\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '沿温泉大道向东北步行1263米左转',\n",
       "  'orientation': '东北',\n",
       "  'road': '温泉大道',\n",
       "  'distance': '1263',\n",
       "  'duration': '1010',\n",
       "  'polyline': '113.647977,23.62339;113.648129,23.623442;113.6499,23.624961;113.6499,23.624961;113.650213,23.625226;113.650556,23.625456;113.650556,23.625456;113.650985,23.625747;113.65135,23.626037;113.65135,23.626037;113.652639,23.62727;113.652739,23.627409;113.652739,23.627409;113.653602,23.628077;113.65441,23.628637;113.65441,23.628637;113.655273,23.629167;113.655273,23.629167;113.6576,23.630543',\n",
       "  'action': '左转',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '向西北步行13米右转',\n",
       "  'orientation': '西北',\n",
       "  'road': [],\n",
       "  'distance': '13',\n",
       "  'duration': '10',\n",
       "  'polyline': '113.6576,23.630543;113.657535,23.630651',\n",
       "  'action': '右转',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '沿温泉大道向东北步行85米向左前方行走',\n",
       "  'orientation': '东北',\n",
       "  'road': '温泉大道',\n",
       "  'distance': '85',\n",
       "  'duration': '68',\n",
       "  'polyline': '113.65753,23.630651;113.658216,23.631102',\n",
       "  'action': '向左前方行走',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '沿温泉大道步行204米直行',\n",
       "  'orientation': [],\n",
       "  'road': '温泉大道',\n",
       "  'distance': '204',\n",
       "  'duration': '163',\n",
       "  'polyline': '113.658216,23.631102;113.658359,23.631263;113.658485,23.63145;113.65878,23.631966;113.65878,23.631966;113.658859,23.632105;113.658859,23.632105;113.659002,23.632461;113.659102,23.632747',\n",
       "  'action': '直行',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '沿景泉大道向北步行803米向左前方行走',\n",
       "  'orientation': '北',\n",
       "  'road': '景泉大道',\n",
       "  'distance': '803',\n",
       "  'duration': '642',\n",
       "  'polyline': '113.659102,23.632747;113.659123,23.633151;113.659123,23.633151;113.659141,23.633429;113.659119,23.633754;113.659028,23.634579;113.658806,23.636102;113.658806,23.636102;113.65855,23.638442;113.65855,23.638442;113.65849,23.638911;113.65849,23.638911;113.65842,23.63947;113.65842,23.63947;113.658411,23.639805;113.658411,23.639805;113.658381,23.63987;113.658381,23.63987;113.658364,23.639926;113.658377,23.639987',\n",
       "  'action': '向左前方行走',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '沿景泉大道向西北步行54米直行',\n",
       "  'orientation': '西北',\n",
       "  'road': '景泉大道',\n",
       "  'distance': '54',\n",
       "  'duration': '43',\n",
       "  'polyline': '113.658377,23.639987;113.658129,23.640417',\n",
       "  'action': '直行',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '沿温泉东路向西北步行194米左转',\n",
       "  'orientation': '西北',\n",
       "  'road': '温泉东路',\n",
       "  'distance': '194',\n",
       "  'duration': '155',\n",
       "  'polyline': '113.658125,23.640417;113.658038,23.640543;113.658038,23.640543;113.657739,23.640933;113.657739,23.640933;113.657626,23.641124;113.657626,23.641124;113.657526,23.641246;113.657526,23.641246;113.657444,23.641363;113.657444,23.641363;113.657062,23.641901',\n",
       "  'action': '左转',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '向西步行68米左转',\n",
       "  'orientation': '西',\n",
       "  'road': [],\n",
       "  'distance': '68',\n",
       "  'duration': '54',\n",
       "  'polyline': '113.657057,23.641901;113.656931,23.641827;113.656879,23.641819;113.65674,23.64184;113.65661,23.641914;113.65661,23.641914;113.656437,23.641923',\n",
       "  'action': '左转',\n",
       "  'assistant_action': [],\n",
       "  'walk_type': '0'},\n",
       " {'instruction': '向西步行114米到达目的地',\n",
       "  'orientation': '西',\n",
       "  'road': [],\n",
       "  'distance': '114',\n",
       "  'duration': '91',\n",
       "  'polyline': '113.656432,23.641923;113.656428,23.641871;113.656398,23.641819;113.656276,23.641745;113.656176,23.641714;113.656176,23.641714;113.656016,23.641684;113.655872,23.641675;113.655421,23.641701',\n",
       "  'action': [],\n",
       "  'assistant_action': '到达目的地',\n",
       "  'walk_type': '0'}]"
      ]
     },
     "execution_count": 201,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "walk(chen_key,起始点,目的地)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 应用场景\n",
    "步行路径规划返回的路线信息列表中含有步行时间、距离，可以用于与其他交通方式j进行对比，还有具体的步行指示可用于导航"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 公交\n",
    "* 1、url：https://restapi.amap.com/v3/direction/transit/integrated?parameters  \n",
    "* 2、requests.get()   \n",
    "* 3、参数  \n",
    "    A.必选：key，origin，destination，city  \n",
    "    B.可选：cityd（跨城公交），extensions（默认值base），strategy（默认值0），nightflag，date，time,sig,output(默认JSON)，callback"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 202,
   "metadata": {},
   "outputs": [],
   "source": [
    "#数据准备\n",
    "mycity = \"广州\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 207,
   "metadata": {},
   "outputs": [],
   "source": [
    "#公交\n",
    "def bus(key,origin,destination,city,cityd=None,extensions=\"base\",strategy=0,nightflag=None,date=None,time=None,sig=None,output=\"JSON\",callback=None):\n",
    "    \"\"\"获取公交路径规划 \n",
    "    可以规划综合各类公共（火车、公交、地铁）交通方式的通勤方案，并且返回通勤方案的数据。\"\"\"\n",
    "    url = \"https://restapi.amap.com/v3/direction/transit/integrated?parameters\"\n",
    "    params = {\n",
    "    \"key\":key,\n",
    "    \"origin\":origin,\n",
    "    \"destination\":destination,\n",
    "    \"city\":city,\n",
    "    \"cityd\":cityd,\n",
    "    \"extensions\":extensions,\n",
    "    \"strategy\":strategy,\n",
    "    \"nightflag\":nightflag,\n",
    "    \"date\":date,\n",
    "    \"time\":time,\n",
    "    \"sig\":sig,\n",
    "    \"output\":output,\n",
    "    \"callback\":callback\n",
    "    }\n",
    "    r = requests.get(url,params)\n",
    "    results = r.json()['route']\n",
    "    return results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 208,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'origin': '113.679287,23.632575',\n",
       " 'destination': '113.655442,23.641986',\n",
       " 'distance': '3181',\n",
       " 'taxi_cost': '20',\n",
       " 'transits': [{'cost': [],\n",
       "   'duration': '3225',\n",
       "   'nightflag': '0',\n",
       "   'walking_distance': '928',\n",
       "   'distance': '7612',\n",
       "   'missed': '0',\n",
       "   'segments': [{'taxi': [],\n",
       "     'walking': {'origin': '113.679016,23.632349',\n",
       "      'destination': '113.676613,23.631285',\n",
       "      'distance': '513',\n",
       "      'duration': '439',\n",
       "      'steps': [{'instruction': '步行57米右转',\n",
       "        'road': [],\n",
       "        'distance': '57',\n",
       "        'duration': [],\n",
       "        'polyline': '113.679016,23.632349;113.678528,23.632097',\n",
       "        'action': '右转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行47米向左前方行走',\n",
       "        'road': [],\n",
       "        'distance': '47',\n",
       "        'duration': [],\n",
       "        'polyline': '113.678528,23.632092;113.678398,23.632166;113.678101,23.632261',\n",
       "        'action': '向左前方行走',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行218米左转',\n",
       "        'road': [],\n",
       "        'distance': '218',\n",
       "        'duration': [],\n",
       "        'polyline': '113.678101,23.632261;113.677834,23.632261;113.677551,23.632200;113.677399,23.632179;113.677284,23.632200;113.677177,23.632244;113.677017,23.632357;113.676811,23.632534;113.676582,23.632778;113.676430,23.632904;113.676292,23.632969',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '沿博学路步行191米到达中大南方学院',\n",
       "        'road': '博学路',\n",
       "        'distance': '191',\n",
       "        'duration': [],\n",
       "        'polyline': '113.676285,23.632969;113.676292,23.632227;113.676338,23.631948;113.676430,23.631676;113.676491,23.631540;113.676613,23.631285',\n",
       "        'action': [],\n",
       "        'assistant_action': '到达中大南方学院'}]},\n",
       "     'bus': {'buslines': [{'departure_stop': {'name': '中大南方学院',\n",
       "         'id': '900000111141002',\n",
       "         'location': '113.676613,23.631281'},\n",
       "        'arrival_stop': {'name': '交警温泉中队',\n",
       "         'id': '900000111141029',\n",
       "         'location': '113.656944,23.630304'},\n",
       "        'name': '从15路(中大南方学院--从化汽车站总站)',\n",
       "        'id': '900000111141',\n",
       "        'type': '普通公交线路',\n",
       "        'distance': '5371',\n",
       "        'duration': '1631',\n",
       "        'polyline': '113.676613,23.631281;113.676460,23.631588;113.676430,23.631672;113.676338,23.631945;113.676292,23.632223;113.676285,23.632969;113.676285,23.633560;113.676300,23.633738;113.676331,23.633875;113.676399,23.634016;113.676460,23.634111;113.676521,23.634193;113.676781,23.634409;113.676857,23.634357;113.676933,23.634340;113.677032,23.634354;113.677094,23.634396;113.677139,23.634459;113.677147,23.634535;113.677139,23.634600;113.677086,23.634663;113.677032,23.634701;113.676918,23.634718;113.676857,23.634701;113.676788,23.634657;113.675262,23.636129;113.675156,23.636263;113.675026,23.636467;113.674973,23.636566;113.674957,23.636702;113.674957,23.636845;113.674995,23.636995;113.675377,23.637886;113.675430,23.638042;113.675522,23.638659;113.675529,23.638998;113.675514,23.639132;113.675446,23.639311;113.675331,23.639582;113.675102,23.640036;113.675003,23.640186;113.674309,23.641024;113.673347,23.642139;113.672981,23.642536;113.672935,23.642578;113.672173,23.643307;113.671707,23.643766;113.671432,23.644045;113.673103,23.644968;113.674362,23.645651;113.675461,23.646276;113.675964,23.646635;113.676407,23.647018;113.676376,23.647089;113.675964,23.646744;113.675735,23.646566;113.675468,23.646385;113.675095,23.646172;113.673004,23.645004;113.669968,23.643330;113.669167,23.642881;113.668770,23.642673;113.668594,23.642578;113.667007,23.641693;113.666145,23.641171;113.665314,23.640564;113.665253,23.640511;113.665016,23.640301;113.664772,23.640064;113.664551,23.639812;113.664406,23.639662;113.664207,23.639400;113.663925,23.639021;113.663574,23.638451;113.663361,23.638020;113.662323,23.635933;113.661949,23.635181;113.661461,23.634266;113.661224,23.633898;113.660843,23.633383;113.660683,23.633192;113.660248,23.632704;113.659721,23.632172;113.659370,23.631880;113.659256,23.631794;113.658989,23.631588;113.658897,23.631519;113.658211,23.631102;113.657707,23.630760;113.657425,23.630590;113.656944,23.630304',\n",
       "        'bustimetag': '0',\n",
       "        'start_time': '0900',\n",
       "        'end_time': '1800',\n",
       "        'via_num': '1',\n",
       "        'via_stops': [{'name': '卫东',\n",
       "          'id': '900000111141003',\n",
       "          'location': '113.671707,23.643766'}]}]},\n",
       "     'entrance': [],\n",
       "     'exit': [],\n",
       "     'railway': {'via_stops': [], 'alters': [], 'spaces': []}},\n",
       "    {'taxi': [],\n",
       "     'walking': {'origin': '113.656944,23.630299',\n",
       "      'destination': '113.657127,23.630264',\n",
       "      'distance': '141',\n",
       "      'duration': '120',\n",
       "      'steps': [{'instruction': '沿温泉大道步行71米右转',\n",
       "        'road': '温泉大道',\n",
       "        'distance': '71',\n",
       "        'duration': [],\n",
       "        'polyline': '113.656944,23.630299;113.657532,23.630651',\n",
       "        'action': '右转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行13米右转',\n",
       "        'road': [],\n",
       "        'distance': '13',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657532,23.630651;113.657600,23.630547',\n",
       "        'action': '右转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '沿温泉大道步行57米到达交警温泉中队',\n",
       "        'road': '温泉大道',\n",
       "        'distance': '57',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657600,23.630543;113.657127,23.630264',\n",
       "        'action': [],\n",
       "        'assistant_action': '到达交警温泉中队'}]},\n",
       "     'bus': {'buslines': [{'departure_stop': {'name': '交警温泉中队',\n",
       "         'id': '900000118740006',\n",
       "         'location': '113.657122,23.630265'},\n",
       "        'arrival_stop': {'name': '温泉农贸市场',\n",
       "         'id': '900000118740007',\n",
       "         'location': '113.657562,23.641193'},\n",
       "        'name': '从4路快线(从化汽车站总站--温泉明月山溪总站)',\n",
       "        'id': '900000118740',\n",
       "        'type': '普通公交线路',\n",
       "        'distance': '1313',\n",
       "        'duration': '799',\n",
       "        'polyline': '113.657122,23.630265;113.657127,23.630264;113.657120,23.630264;113.657509,23.630495;113.658340,23.631012;113.659050,23.631502;113.659164,23.631588;113.659386,23.631748;113.659370,23.631880;113.659286,23.632261;113.659256,23.632561;113.659233,23.632986;113.659256,23.633408;113.659256,23.633615;113.658958,23.636133;113.658569,23.639326;113.658569,23.639526;113.658661,23.639769;113.658730,23.639862;113.658745,23.639956;113.658699,23.640036;113.658623,23.640091;113.658524,23.640104;113.658180,23.640360;113.658096,23.640465;113.658028,23.640543;113.657776,23.640884;113.657616,23.641125;113.657562,23.641193',\n",
       "        'bustimetag': '3',\n",
       "        'start_time': [],\n",
       "        'end_time': [],\n",
       "        'via_num': '0',\n",
       "        'via_stops': []},\n",
       "       {'departure_stop': {'name': '交警温泉中队',\n",
       "         'id': '440100017383032',\n",
       "         'location': '113.657028,23.630203'},\n",
       "        'arrival_stop': {'name': '温泉农贸市场',\n",
       "         'id': '440100017383075',\n",
       "         'location': '113.657562,23.641193'},\n",
       "        'name': '从4路(从化汽车站总站--温泉明月山溪总站)',\n",
       "        'id': '440100017383',\n",
       "        'type': '普通公交线路',\n",
       "        'distance': '1362',\n",
       "        'duration': '801',\n",
       "        'polyline': '113.657028,23.630203;113.657021,23.630205;113.657509,23.630495;113.658340,23.631012;113.659050,23.631502;113.659164,23.631588;113.659386,23.631748;113.659370,23.631880;113.659286,23.632261;113.659256,23.632561;113.659233,23.632986;113.659256,23.633408;113.659256,23.633615;113.658958,23.636133;113.658897,23.636612;113.658569,23.639326;113.658569,23.639526;113.658661,23.639769;113.658722,23.639835;113.658745,23.639883;113.658745,23.639956;113.658699,23.640036;113.658623,23.640091;113.658524,23.640104;113.658180,23.640360;113.658096,23.640465;113.658028,23.640543;113.657776,23.640884;113.657616,23.641125;113.657562,23.641193',\n",
       "        'bustimetag': '3',\n",
       "        'start_time': '0600',\n",
       "        'end_time': '2130',\n",
       "        'via_num': '1',\n",
       "        'via_stops': [{'name': '富力泉天下',\n",
       "          'id': '440100017383049',\n",
       "          'location': '113.658897,23.636612'}]}]},\n",
       "     'entrance': [],\n",
       "     'exit': [],\n",
       "     'railway': {'via_stops': [], 'alters': [], 'spaces': []}},\n",
       "    {'taxi': [],\n",
       "     'walking': {'origin': '113.657562,23.641193',\n",
       "      'destination': '113.655418,23.641701',\n",
       "      'distance': '274',\n",
       "      'duration': '234',\n",
       "      'steps': [{'instruction': '沿温泉东路步行92米左转',\n",
       "        'road': '温泉东路',\n",
       "        'distance': '92',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657562,23.641193;113.657524,23.641245;113.657440,23.641363;113.657059,23.641901',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行68米左转',\n",
       "        'road': [],\n",
       "        'distance': '68',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657059,23.641901;113.656929,23.641827;113.656876,23.641819;113.656738,23.641840;113.656609,23.641914;113.656433,23.641922',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行114米',\n",
       "        'road': [],\n",
       "        'distance': '114',\n",
       "        'duration': [],\n",
       "        'polyline': '113.656433,23.641922;113.656425,23.641870;113.656395,23.641819;113.656273,23.641745;113.656174,23.641714;113.656013,23.641684;113.655876,23.641676;113.655418,23.641701',\n",
       "        'action': [],\n",
       "        'assistant_action': []}]},\n",
       "     'bus': {'buslines': []},\n",
       "     'entrance': [],\n",
       "     'exit': [],\n",
       "     'railway': {'via_stops': [], 'alters': [], 'spaces': []}}]},\n",
       "  {'cost': [],\n",
       "   'duration': '3263',\n",
       "   'nightflag': '0',\n",
       "   'walking_distance': '928',\n",
       "   'distance': '7668',\n",
       "   'missed': '0',\n",
       "   'segments': [{'taxi': [],\n",
       "     'walking': {'origin': '113.679016,23.632349',\n",
       "      'destination': '113.676613,23.631285',\n",
       "      'distance': '513',\n",
       "      'duration': '439',\n",
       "      'steps': [{'instruction': '步行57米右转',\n",
       "        'road': [],\n",
       "        'distance': '57',\n",
       "        'duration': [],\n",
       "        'polyline': '113.679016,23.632349;113.678528,23.632097',\n",
       "        'action': '右转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行47米向左前方行走',\n",
       "        'road': [],\n",
       "        'distance': '47',\n",
       "        'duration': [],\n",
       "        'polyline': '113.678528,23.632092;113.678398,23.632166;113.678101,23.632261',\n",
       "        'action': '向左前方行走',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行218米左转',\n",
       "        'road': [],\n",
       "        'distance': '218',\n",
       "        'duration': [],\n",
       "        'polyline': '113.678101,23.632261;113.677834,23.632261;113.677551,23.632200;113.677399,23.632179;113.677284,23.632200;113.677177,23.632244;113.677017,23.632357;113.676811,23.632534;113.676582,23.632778;113.676430,23.632904;113.676292,23.632969',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '沿博学路步行191米到达中大南方学院',\n",
       "        'road': '博学路',\n",
       "        'distance': '191',\n",
       "        'duration': [],\n",
       "        'polyline': '113.676285,23.632969;113.676292,23.632227;113.676338,23.631948;113.676430,23.631676;113.676491,23.631540;113.676613,23.631285',\n",
       "        'action': [],\n",
       "        'assistant_action': '到达中大南方学院'}]},\n",
       "     'bus': {'buslines': [{'departure_stop': {'name': '中大南方学院',\n",
       "         'id': '900000111141002',\n",
       "         'location': '113.676613,23.631281'},\n",
       "        'arrival_stop': {'name': '交警温泉中队',\n",
       "         'id': '900000111141029',\n",
       "         'location': '113.656944,23.630304'},\n",
       "        'name': '从15路(中大南方学院--从化汽车站总站)',\n",
       "        'id': '900000111141',\n",
       "        'type': '普通公交线路',\n",
       "        'distance': '5371',\n",
       "        'duration': '1631',\n",
       "        'polyline': '113.676613,23.631281;113.676460,23.631588;113.676430,23.631672;113.676338,23.631945;113.676292,23.632223;113.676285,23.632969;113.676285,23.633560;113.676300,23.633738;113.676331,23.633875;113.676399,23.634016;113.676460,23.634111;113.676521,23.634193;113.676781,23.634409;113.676857,23.634357;113.676933,23.634340;113.677032,23.634354;113.677094,23.634396;113.677139,23.634459;113.677147,23.634535;113.677139,23.634600;113.677086,23.634663;113.677032,23.634701;113.676918,23.634718;113.676857,23.634701;113.676788,23.634657;113.675262,23.636129;113.675156,23.636263;113.675026,23.636467;113.674973,23.636566;113.674957,23.636702;113.674957,23.636845;113.674995,23.636995;113.675377,23.637886;113.675430,23.638042;113.675522,23.638659;113.675529,23.638998;113.675514,23.639132;113.675446,23.639311;113.675331,23.639582;113.675102,23.640036;113.675003,23.640186;113.674309,23.641024;113.673347,23.642139;113.672981,23.642536;113.672935,23.642578;113.672173,23.643307;113.671707,23.643766;113.671432,23.644045;113.673103,23.644968;113.674362,23.645651;113.675461,23.646276;113.675964,23.646635;113.676407,23.647018;113.676376,23.647089;113.675964,23.646744;113.675735,23.646566;113.675468,23.646385;113.675095,23.646172;113.673004,23.645004;113.669968,23.643330;113.669167,23.642881;113.668770,23.642673;113.668594,23.642578;113.667007,23.641693;113.666145,23.641171;113.665314,23.640564;113.665253,23.640511;113.665016,23.640301;113.664772,23.640064;113.664551,23.639812;113.664406,23.639662;113.664207,23.639400;113.663925,23.639021;113.663574,23.638451;113.663361,23.638020;113.662323,23.635933;113.661949,23.635181;113.661461,23.634266;113.661224,23.633898;113.660843,23.633383;113.660683,23.633192;113.660248,23.632704;113.659721,23.632172;113.659370,23.631880;113.659256,23.631794;113.658989,23.631588;113.658897,23.631519;113.658211,23.631102;113.657707,23.630760;113.657425,23.630590;113.656944,23.630304',\n",
       "        'bustimetag': '0',\n",
       "        'start_time': '0900',\n",
       "        'end_time': '1800',\n",
       "        'via_num': '1',\n",
       "        'via_stops': [{'name': '卫东',\n",
       "          'id': '900000111141003',\n",
       "          'location': '113.671707,23.643766'}]}]},\n",
       "     'entrance': [],\n",
       "     'exit': [],\n",
       "     'railway': {'via_stops': [], 'alters': [], 'spaces': []}},\n",
       "    {'taxi': [],\n",
       "     'walking': {'origin': '113.656929,23.630295',\n",
       "      'destination': '113.657135,23.630274',\n",
       "      'distance': '141',\n",
       "      'duration': '120',\n",
       "      'steps': [{'instruction': '沿温泉大道步行72米右转',\n",
       "        'road': '温泉大道',\n",
       "        'distance': '72',\n",
       "        'duration': [],\n",
       "        'polyline': '113.656929,23.630295;113.657532,23.630651',\n",
       "        'action': '右转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行13米右转',\n",
       "        'road': [],\n",
       "        'distance': '13',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657532,23.630651;113.657600,23.630547',\n",
       "        'action': '右转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '沿温泉大道步行56米到达温泉中队',\n",
       "        'road': '温泉大道',\n",
       "        'distance': '56',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657600,23.630543;113.657135,23.630274',\n",
       "        'action': [],\n",
       "        'assistant_action': '到达温泉中队'}]},\n",
       "     'bus': {'buslines': [{'departure_stop': {'name': '温泉中队',\n",
       "         'id': '900000077948032',\n",
       "         'location': '113.657135,23.630270'},\n",
       "        'arrival_stop': {'name': '温泉农贸市场',\n",
       "         'id': '900000077948034',\n",
       "         'location': '113.657570,23.641180'},\n",
       "        'name': '从4路短线(从化汽车站总站--温泉农贸市场)',\n",
       "        'id': '900000077948',\n",
       "        'type': '普通公交线路',\n",
       "        'distance': '1369',\n",
       "        'duration': '837',\n",
       "        'polyline': '113.657135,23.630270;113.657516,23.630495;113.658333,23.631006;113.658836,23.631350;113.659439,23.631788;113.659462,23.631958;113.659302,23.632952;113.659286,23.633064;113.659210,23.633953;113.659073,23.635075;113.658951,23.636133;113.658890,23.636566;113.658905,23.636566;113.658569,23.639326;113.658569,23.639526;113.658661,23.639769;113.658730,23.639862;113.658745,23.639956;113.658699,23.640036;113.658623,23.640091;113.658524,23.640104;113.658180,23.640360;113.658096,23.640465;113.658028,23.640543;113.657776,23.640884;113.657616,23.641125;113.657570,23.641180',\n",
       "        'bustimetag': '0',\n",
       "        'start_time': '0800',\n",
       "        'end_time': '2000',\n",
       "        'via_num': '1',\n",
       "        'via_stops': [{'name': '富力泉天下',\n",
       "          'id': '900000077948033',\n",
       "          'location': '113.658890,23.636566'}]}]},\n",
       "     'entrance': [],\n",
       "     'exit': [],\n",
       "     'railway': {'via_stops': [], 'alters': [], 'spaces': []}},\n",
       "    {'taxi': [],\n",
       "     'walking': {'origin': '113.657562,23.641193',\n",
       "      'destination': '113.655418,23.641701',\n",
       "      'distance': '274',\n",
       "      'duration': '234',\n",
       "      'steps': [{'instruction': '沿温泉东路步行92米左转',\n",
       "        'road': '温泉东路',\n",
       "        'distance': '92',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657562,23.641193;113.657524,23.641245;113.657440,23.641363;113.657059,23.641901',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行68米左转',\n",
       "        'road': [],\n",
       "        'distance': '68',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657059,23.641901;113.656929,23.641827;113.656876,23.641819;113.656738,23.641840;113.656609,23.641914;113.656433,23.641922',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行114米',\n",
       "        'road': [],\n",
       "        'distance': '114',\n",
       "        'duration': [],\n",
       "        'polyline': '113.656433,23.641922;113.656425,23.641870;113.656395,23.641819;113.656273,23.641745;113.656174,23.641714;113.656013,23.641684;113.655876,23.641676;113.655418,23.641701',\n",
       "        'action': [],\n",
       "        'assistant_action': []}]},\n",
       "     'bus': {'buslines': []},\n",
       "     'entrance': [],\n",
       "     'exit': [],\n",
       "     'railway': {'via_stops': [], 'alters': [], 'spaces': []}}]},\n",
       "  {'cost': '2.0',\n",
       "   'duration': '3417',\n",
       "   'nightflag': '0',\n",
       "   'walking_distance': '2084',\n",
       "   'distance': '7455',\n",
       "   'missed': '0',\n",
       "   'segments': [{'taxi': [],\n",
       "     'walking': {'origin': '113.679016,23.632349',\n",
       "      'destination': '113.676613,23.631285',\n",
       "      'distance': '513',\n",
       "      'duration': '439',\n",
       "      'steps': [{'instruction': '步行57米右转',\n",
       "        'road': [],\n",
       "        'distance': '57',\n",
       "        'duration': [],\n",
       "        'polyline': '113.679016,23.632349;113.678528,23.632097',\n",
       "        'action': '右转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行47米向左前方行走',\n",
       "        'road': [],\n",
       "        'distance': '47',\n",
       "        'duration': [],\n",
       "        'polyline': '113.678528,23.632092;113.678398,23.632166;113.678101,23.632261',\n",
       "        'action': '向左前方行走',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行218米左转',\n",
       "        'road': [],\n",
       "        'distance': '218',\n",
       "        'duration': [],\n",
       "        'polyline': '113.678101,23.632261;113.677834,23.632261;113.677551,23.632200;113.677399,23.632179;113.677284,23.632200;113.677177,23.632244;113.677017,23.632357;113.676811,23.632534;113.676582,23.632778;113.676430,23.632904;113.676292,23.632969',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '沿博学路步行191米到达中大南方学院',\n",
       "        'road': '博学路',\n",
       "        'distance': '191',\n",
       "        'duration': [],\n",
       "        'polyline': '113.676285,23.632969;113.676292,23.632227;113.676338,23.631948;113.676430,23.631676;113.676491,23.631540;113.676613,23.631285',\n",
       "        'action': [],\n",
       "        'assistant_action': '到达中大南方学院'}]},\n",
       "     'bus': {'buslines': [{'departure_stop': {'name': '中大南方学院',\n",
       "         'id': '900000111141002',\n",
       "         'location': '113.676613,23.631281'},\n",
       "        'arrival_stop': {'name': '交警温泉中队',\n",
       "         'id': '900000111141029',\n",
       "         'location': '113.656944,23.630304'},\n",
       "        'name': '从15路(中大南方学院--从化汽车站总站)',\n",
       "        'id': '900000111141',\n",
       "        'type': '普通公交线路',\n",
       "        'distance': '5371',\n",
       "        'duration': '1631',\n",
       "        'polyline': '113.676613,23.631281;113.676460,23.631588;113.676430,23.631672;113.676338,23.631945;113.676292,23.632223;113.676285,23.632969;113.676285,23.633560;113.676300,23.633738;113.676331,23.633875;113.676399,23.634016;113.676460,23.634111;113.676521,23.634193;113.676781,23.634409;113.676857,23.634357;113.676933,23.634340;113.677032,23.634354;113.677094,23.634396;113.677139,23.634459;113.677147,23.634535;113.677139,23.634600;113.677086,23.634663;113.677032,23.634701;113.676918,23.634718;113.676857,23.634701;113.676788,23.634657;113.675262,23.636129;113.675156,23.636263;113.675026,23.636467;113.674973,23.636566;113.674957,23.636702;113.674957,23.636845;113.674995,23.636995;113.675377,23.637886;113.675430,23.638042;113.675522,23.638659;113.675529,23.638998;113.675514,23.639132;113.675446,23.639311;113.675331,23.639582;113.675102,23.640036;113.675003,23.640186;113.674309,23.641024;113.673347,23.642139;113.672981,23.642536;113.672935,23.642578;113.672173,23.643307;113.671707,23.643766;113.671432,23.644045;113.673103,23.644968;113.674362,23.645651;113.675461,23.646276;113.675964,23.646635;113.676407,23.647018;113.676376,23.647089;113.675964,23.646744;113.675735,23.646566;113.675468,23.646385;113.675095,23.646172;113.673004,23.645004;113.669968,23.643330;113.669167,23.642881;113.668770,23.642673;113.668594,23.642578;113.667007,23.641693;113.666145,23.641171;113.665314,23.640564;113.665253,23.640511;113.665016,23.640301;113.664772,23.640064;113.664551,23.639812;113.664406,23.639662;113.664207,23.639400;113.663925,23.639021;113.663574,23.638451;113.663361,23.638020;113.662323,23.635933;113.661949,23.635181;113.661461,23.634266;113.661224,23.633898;113.660843,23.633383;113.660683,23.633192;113.660248,23.632704;113.659721,23.632172;113.659370,23.631880;113.659256,23.631794;113.658989,23.631588;113.658897,23.631519;113.658211,23.631102;113.657707,23.630760;113.657425,23.630590;113.656944,23.630304',\n",
       "        'bustimetag': '0',\n",
       "        'start_time': '0900',\n",
       "        'end_time': '1800',\n",
       "        'via_num': '1',\n",
       "        'via_stops': [{'name': '卫东',\n",
       "          'id': '900000111141003',\n",
       "          'location': '113.671707,23.643766'}]}]},\n",
       "     'entrance': [],\n",
       "     'exit': [],\n",
       "     'railway': {'via_stops': [], 'alters': [], 'spaces': []}},\n",
       "    {'taxi': [],\n",
       "     'walking': {'origin': '113.657120,23.630404',\n",
       "      'destination': '113.655418,23.641701',\n",
       "      'distance': '1571',\n",
       "      'duration': '1346',\n",
       "      'steps': [{'instruction': '沿温泉大道步行134米向左前方行走',\n",
       "        'road': '温泉大道',\n",
       "        'distance': '134',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657120,23.630404;113.657532,23.630651;113.658218,23.631102',\n",
       "        'action': '向左前方行走',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '沿温泉大道步行204米往前走',\n",
       "        'road': '温泉大道',\n",
       "        'distance': '204',\n",
       "        'duration': [],\n",
       "        'polyline': '113.658218,23.631102;113.658356,23.631264;113.658485,23.631449;113.658783,23.631966;113.658859,23.632105;113.659004,23.632462;113.659103,23.632748',\n",
       "        'action': '往前走',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '沿景泉大道步行803米向左前方行走',\n",
       "        'road': '景泉大道',\n",
       "        'distance': '803',\n",
       "        'duration': [],\n",
       "        'polyline': '113.659103,23.632748;113.659126,23.633150;113.659142,23.633429;113.659119,23.633755;113.659027,23.634579;113.658806,23.636103;113.658554,23.638441;113.658493,23.638910;113.658417,23.639471;113.658409,23.639805;113.658379,23.639870;113.658363,23.639927;113.658379,23.639986',\n",
       "        'action': '向左前方行走',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '沿景泉大道步行54米往前走',\n",
       "        'road': '景泉大道',\n",
       "        'distance': '54',\n",
       "        'duration': [],\n",
       "        'polyline': '113.658379,23.639986;113.658127,23.640417',\n",
       "        'action': '往前走',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '沿温泉东路步行194米左转',\n",
       "        'road': '温泉东路',\n",
       "        'distance': '194',\n",
       "        'duration': [],\n",
       "        'polyline': '113.658127,23.640417;113.658035,23.640543;113.657738,23.640934;113.657623,23.641125;113.657524,23.641245;113.657440,23.641363;113.657059,23.641901',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行68米左转',\n",
       "        'road': [],\n",
       "        'distance': '68',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657059,23.641901;113.656929,23.641827;113.656876,23.641819;113.656738,23.641840;113.656609,23.641914;113.656433,23.641922',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行114米',\n",
       "        'road': [],\n",
       "        'distance': '114',\n",
       "        'duration': [],\n",
       "        'polyline': '113.656433,23.641922;113.656425,23.641870;113.656395,23.641819;113.656273,23.641745;113.656174,23.641714;113.656013,23.641684;113.655876,23.641676;113.655418,23.641701',\n",
       "        'action': [],\n",
       "        'assistant_action': []}]},\n",
       "     'bus': {'buslines': []},\n",
       "     'entrance': [],\n",
       "     'exit': [],\n",
       "     'railway': {'via_stops': [], 'alters': [], 'spaces': []}}]},\n",
       "  {'cost': [],\n",
       "   'duration': '5249',\n",
       "   'nightflag': '0',\n",
       "   'walking_distance': '2350',\n",
       "   'distance': '8899',\n",
       "   'missed': '0',\n",
       "   'segments': [{'taxi': [],\n",
       "     'walking': {'origin': '113.679588,23.632492',\n",
       "      'destination': '113.675644,23.619991',\n",
       "      'distance': '1957',\n",
       "      'duration': '1677',\n",
       "      'steps': [{'instruction': '步行101米右转',\n",
       "        'road': [],\n",
       "        'distance': '101',\n",
       "        'duration': [],\n",
       "        'polyline': '113.679588,23.632492;113.680588,23.632523',\n",
       "        'action': '右转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行199米向右前方行走',\n",
       "        'road': [],\n",
       "        'distance': '199',\n",
       "        'duration': [],\n",
       "        'polyline': '113.680588,23.632523;113.680641,23.632139;113.680672,23.631741;113.680634,23.631540;113.680588,23.631437;113.680496,23.631241;113.680405,23.631094;113.680206,23.630842',\n",
       "        'action': '向右前方行走',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行159米左转',\n",
       "        'road': [],\n",
       "        'distance': '159',\n",
       "        'duration': [],\n",
       "        'polyline': '113.680206,23.630838;113.680038,23.630772;113.679642,23.630638;113.679359,23.630522;113.679199,23.630472;113.679031,23.630430;113.678879,23.630404;113.678711,23.630365',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行237米左转',\n",
       "        'road': [],\n",
       "        'distance': '237',\n",
       "        'duration': [],\n",
       "        'polyline': '113.678711,23.630360;113.678711,23.629341;113.678711,23.629192;113.678688,23.629084;113.678635,23.629023;113.678421,23.628902;113.678368,23.628841;113.678314,23.628723;113.678291,23.628611;113.678276,23.628372',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行498米向右前方行走',\n",
       "        'road': [],\n",
       "        'distance': '498',\n",
       "        'duration': [],\n",
       "        'polyline': '113.678276,23.628368;113.678574,23.628338;113.678688,23.628307;113.678848,23.628233;113.679047,23.628073;113.679161,23.627964;113.679214,23.627869;113.679237,23.627777;113.679283,23.627525;113.679291,23.627321;113.679253,23.626854;113.679184,23.626623;113.679138,23.626497;113.679001,23.626259;113.678940,23.626177;113.678711,23.625977;113.678619,23.625864;113.678528,23.625721;113.678436,23.625191;113.678429,23.625057;113.678452,23.624939;113.678574,23.624657',\n",
       "        'action': '向右前方行走',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行722米左转',\n",
       "        'road': [],\n",
       "        'distance': '722',\n",
       "        'duration': [],\n",
       "        'polyline': '113.678574,23.624653;113.678558,23.624510;113.678413,23.624323;113.677582,23.623793;113.676529,23.623346;113.676361,23.623255;113.676270,23.623152;113.676109,23.622833;113.676041,23.622738;113.675789,23.622482;113.675499,23.622278;113.675415,23.622175;113.675385,23.622087;113.675377,23.621836;113.675392,23.621611;113.675430,23.621475;113.675545,23.621359;113.675766,23.621181;113.675850,23.621090;113.675903,23.620995;113.675903,23.620855;113.675880,23.620726;113.675743,23.620546;113.675598,23.620373;113.675240,23.620012',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行41米到达松浪社',\n",
       "        'road': [],\n",
       "        'distance': '41',\n",
       "        'duration': [],\n",
       "        'polyline': '113.675240,23.620008;113.675491,23.620012;113.675644,23.619991;113.675644,23.619991',\n",
       "        'action': [],\n",
       "        'assistant_action': '到达松浪社'}]},\n",
       "     'bus': {'buslines': [{'departure_stop': {'name': '松浪社',\n",
       "         'id': '900000111143034',\n",
       "         'location': '113.675629,23.619987'},\n",
       "        'arrival_stop': {'name': '温泉交警中队',\n",
       "         'id': '900000111143003',\n",
       "         'location': '113.657120,23.630409'},\n",
       "        'name': '从20路(乌土村委总站--从化汽车站总站)',\n",
       "        'id': '900000111143',\n",
       "        'type': '普通公交线路',\n",
       "        'distance': '5180',\n",
       "        'duration': '2439',\n",
       "        'polyline': '113.675629,23.619987;113.675301,23.620045;113.675201,23.619968;113.674934,23.619713;113.673920,23.618620;113.673691,23.618429;113.673454,23.618334;113.673218,23.618269;113.671082,23.617786;113.667892,23.617096;113.666336,23.616735;113.665916,23.616650;113.664551,23.616346;113.663689,23.616152;113.663544,23.616119;113.663223,23.616043;113.662567,23.615911;113.662025,23.615803;113.661682,23.615711;113.660400,23.615417;113.660004,23.615669;113.659927,23.615711;113.659088,23.616234;113.657166,23.617487;113.656975,23.617626;113.656815,23.617783;113.655830,23.618845;113.655678,23.618971;113.655548,23.619076;113.655411,23.619141;113.655281,23.619188;113.655083,23.619236;113.654747,23.619293;113.654518,23.619307;113.654320,23.619303;113.653976,23.619244;113.652885,23.619011;113.652718,23.618984;113.652573,23.618984;113.652428,23.619015;113.651825,23.619240;113.650818,23.619617;113.649361,23.619949;113.648819,23.620077;113.648354,23.620222;113.648087,23.620314;113.647858,23.620438;113.647621,23.620604;113.647377,23.620783;113.647179,23.620893;113.646973,23.620993;113.646477,23.621176;113.646317,23.621258;113.645866,23.621567;113.645721,23.621698;113.645721,23.621876;113.645821,23.622089;113.646248,23.622282;113.646629,23.622496;113.647217,23.622856;113.647697,23.623178;113.648071,23.623466;113.649094,23.624311;113.649666,23.624836;113.649811,23.624950;113.650055,23.625156;113.650192,23.625296;113.652588,23.627287;113.652748,23.627409;113.653603,23.628078;113.654411,23.628637;113.655273,23.629168;113.657509,23.630495;113.657425,23.630590;113.657120,23.630409',\n",
       "        'bustimetag': '0',\n",
       "        'start_time': '0830',\n",
       "        'end_time': '1900',\n",
       "        'via_num': '2',\n",
       "        'via_stops': [{'name': '源湖村五社',\n",
       "          'id': '900000111143035',\n",
       "          'location': '113.663689,23.616152'},\n",
       "         {'name': '源湖村',\n",
       "          'id': '900000111143036',\n",
       "          'location': '113.659927,23.615711'}]}]},\n",
       "     'entrance': [],\n",
       "     'exit': [],\n",
       "     'railway': {'via_stops': [], 'alters': [], 'spaces': []}},\n",
       "    {'taxi': [],\n",
       "     'walking': {'origin': '113.657120,23.630404',\n",
       "      'destination': '113.657127,23.630268',\n",
       "      'distance': '119',\n",
       "      'duration': '102',\n",
       "      'steps': [{'instruction': '沿温泉大道步行49米右转',\n",
       "        'road': '温泉大道',\n",
       "        'distance': '49',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657120,23.630404;113.657532,23.630651',\n",
       "        'action': '右转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行13米右转',\n",
       "        'road': [],\n",
       "        'distance': '13',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657532,23.630651;113.657600,23.630547',\n",
       "        'action': '右转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '沿温泉大道步行57米到达温泉中队',\n",
       "        'road': '温泉大道',\n",
       "        'distance': '57',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657600,23.630543;113.657127,23.630268',\n",
       "        'action': [],\n",
       "        'assistant_action': '到达温泉中队'}]},\n",
       "     'bus': {'buslines': [{'departure_stop': {'name': '温泉中队',\n",
       "         'id': '900000077948032',\n",
       "         'location': '113.657135,23.630270'},\n",
       "        'arrival_stop': {'name': '温泉农贸市场',\n",
       "         'id': '900000077948034',\n",
       "         'location': '113.657570,23.641180'},\n",
       "        'name': '从4路短线(从化汽车站总站--温泉农贸市场)',\n",
       "        'id': '900000077948',\n",
       "        'type': '普通公交线路',\n",
       "        'distance': '1369',\n",
       "        'duration': '796',\n",
       "        'polyline': '113.657135,23.630270;113.657516,23.630495;113.658333,23.631006;113.658836,23.631350;113.659439,23.631788;113.659462,23.631958;113.659302,23.632952;113.659286,23.633064;113.659210,23.633953;113.659073,23.635075;113.658951,23.636133;113.658890,23.636566;113.658905,23.636566;113.658569,23.639326;113.658569,23.639526;113.658661,23.639769;113.658730,23.639862;113.658745,23.639956;113.658699,23.640036;113.658623,23.640091;113.658524,23.640104;113.658180,23.640360;113.658096,23.640465;113.658028,23.640543;113.657776,23.640884;113.657616,23.641125;113.657570,23.641180',\n",
       "        'bustimetag': '0',\n",
       "        'start_time': '0800',\n",
       "        'end_time': '2000',\n",
       "        'via_num': '1',\n",
       "        'via_stops': [{'name': '富力泉天下',\n",
       "          'id': '900000077948033',\n",
       "          'location': '113.658890,23.636566'}]}]},\n",
       "     'entrance': [],\n",
       "     'exit': [],\n",
       "     'railway': {'via_stops': [], 'alters': [], 'spaces': []}},\n",
       "    {'taxi': [],\n",
       "     'walking': {'origin': '113.657562,23.641193',\n",
       "      'destination': '113.655418,23.641701',\n",
       "      'distance': '274',\n",
       "      'duration': '234',\n",
       "      'steps': [{'instruction': '沿温泉东路步行92米左转',\n",
       "        'road': '温泉东路',\n",
       "        'distance': '92',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657562,23.641193;113.657524,23.641245;113.657440,23.641363;113.657059,23.641901',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行68米左转',\n",
       "        'road': [],\n",
       "        'distance': '68',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657059,23.641901;113.656929,23.641827;113.656876,23.641819;113.656738,23.641840;113.656609,23.641914;113.656433,23.641922',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行114米',\n",
       "        'road': [],\n",
       "        'distance': '114',\n",
       "        'duration': [],\n",
       "        'polyline': '113.656433,23.641922;113.656425,23.641870;113.656395,23.641819;113.656273,23.641745;113.656174,23.641714;113.656013,23.641684;113.655876,23.641676;113.655418,23.641701',\n",
       "        'action': [],\n",
       "        'assistant_action': []}]},\n",
       "     'bus': {'buslines': []},\n",
       "     'entrance': [],\n",
       "     'exit': [],\n",
       "     'railway': {'via_stops': [], 'alters': [], 'spaces': []}}]},\n",
       "  {'cost': '1.0',\n",
       "   'duration': '3052',\n",
       "   'nightflag': '0',\n",
       "   'walking_distance': '1998',\n",
       "   'distance': '6167',\n",
       "   'missed': '1',\n",
       "   'segments': [{'taxi': [],\n",
       "     'walking': {'origin': '113.679588,23.632856',\n",
       "      'destination': '113.671761,23.643719',\n",
       "      'distance': '1701',\n",
       "      'duration': '1458',\n",
       "      'steps': [{'instruction': '步行92米向左前方行走',\n",
       "        'road': [],\n",
       "        'distance': '92',\n",
       "        'duration': [],\n",
       "        'polyline': '113.679588,23.632856;113.679588,23.633173;113.679588,23.633251;113.679619,23.633650;113.679649,23.633690',\n",
       "        'action': '向左前方行走',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '沿博学路步行197米左转',\n",
       "        'road': '博学路',\n",
       "        'distance': '197',\n",
       "        'duration': [],\n",
       "        'polyline': '113.679649,23.633690;113.679550,23.633966;113.679375,23.634357;113.679253,23.634480;113.679062,23.634657;113.678932,23.634762;113.678711,23.634918;113.678635,23.634970;113.678596,23.635031;113.678558,23.635109',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '沿博学路步行163米右转',\n",
       "        'road': '博学路',\n",
       "        'distance': '163',\n",
       "        'duration': [],\n",
       "        'polyline': '113.678558,23.635109;113.677856,23.635092;113.677612,23.635035;113.677536,23.634996;113.677330,23.634857;113.677086,23.634670',\n",
       "        'action': '右转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '沿博学路步行33米右转',\n",
       "        'road': '博学路',\n",
       "        'distance': '33',\n",
       "        'duration': [],\n",
       "        'polyline': '113.677086,23.634666;113.677025,23.634701;113.676918,23.634718;113.676857,23.634705;113.676796,23.634661',\n",
       "        'action': '右转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '沿中山路步行1216米到达中大南方',\n",
       "        'road': '中山路',\n",
       "        'distance': '1216',\n",
       "        'duration': [],\n",
       "        'polyline': '113.676796,23.634657;113.675270,23.636129;113.675156,23.636263;113.675026,23.636467;113.674973,23.636566;113.674957,23.636702;113.674957,23.636845;113.674988,23.636997;113.675385,23.637886;113.675430,23.638042;113.675522,23.638659;113.675522,23.638998;113.675507,23.639132;113.675453,23.639311;113.675331,23.639584;113.675110,23.640036;113.675003,23.640186;113.674316,23.641024;113.673363,23.642139;113.672981,23.642534;113.672173,23.643303;113.671761,23.643719',\n",
       "        'action': [],\n",
       "        'assistant_action': '到达中大南方'}]},\n",
       "     'bus': {'buslines': [{'departure_stop': {'name': '中大南方',\n",
       "         'id': '900000111225001',\n",
       "         'location': '113.671753,23.643720'},\n",
       "        'arrival_stop': {'name': '温泉农贸市场',\n",
       "         'id': '900000111225012',\n",
       "         'location': '113.657682,23.641020'},\n",
       "        'name': '从702路(中大南方--乌石村)',\n",
       "        'id': '900000111225',\n",
       "        'type': '微循环公交',\n",
       "        'distance': '4169',\n",
       "        'duration': '1340',\n",
       "        'polyline': '113.671753,23.643720;113.671428,23.644045;113.671636,23.644162;113.673103,23.644970;113.674366,23.645651;113.675460,23.646276;113.675968,23.646636;113.676411,23.647018;113.676367,23.647088;113.675964,23.646745;113.675734,23.646567;113.675464,23.646385;113.675095,23.646172;113.673003,23.645004;113.671827,23.644358;113.671823,23.644358;113.669961,23.643329;113.669162,23.642882;113.668776,23.642674;113.668598,23.642578;113.667001,23.641693;113.666141,23.641172;113.665317,23.640564;113.665252,23.640512;113.665017,23.640299;113.664774,23.640065;113.664549,23.639813;113.664410,23.639661;113.664201,23.639401;113.663928,23.639019;113.663576,23.638451;113.663359,23.638021;113.662322,23.635933;113.661949,23.635182;113.661454,23.634266;113.661224,23.633898;113.660842,23.633381;113.660686,23.633190;113.660252,23.632704;113.660056,23.632613;113.659887,23.632569;113.659666,23.632609;113.659566,23.632648;113.659479,23.632695;113.659379,23.632786;113.659232,23.632986;113.659258,23.633407;113.659232,23.633767;113.659188,23.634154;113.658958,23.636133;113.658902,23.636606;113.658572,23.639327;113.658568,23.639527;113.658659,23.639770;113.658733,23.639861;113.658750,23.639957;113.658707,23.640035;113.658620,23.640091;113.658524,23.640104;113.658177,23.640360;113.658095,23.640464;113.658030,23.640543;113.657734,23.640933;113.657682,23.641020',\n",
       "        'bustimetag': '2',\n",
       "        'start_time': [],\n",
       "        'end_time': [],\n",
       "        'via_num': '2',\n",
       "        'via_stops': [{'name': '卫东',\n",
       "          'id': '900000111225002',\n",
       "          'location': '113.671827,23.644358'},\n",
       "         {'name': '富力泉天下',\n",
       "          'id': '900000111225003',\n",
       "          'location': '113.658902,23.636606'}]}]},\n",
       "     'entrance': [],\n",
       "     'exit': [],\n",
       "     'railway': {'via_stops': [], 'alters': [], 'spaces': []}},\n",
       "    {'taxi': [],\n",
       "     'walking': {'origin': '113.657684,23.641020',\n",
       "      'destination': '113.655418,23.641701',\n",
       "      'distance': '297',\n",
       "      'duration': '254',\n",
       "      'steps': [{'instruction': '沿温泉东路步行115米左转',\n",
       "        'road': '温泉东路',\n",
       "        'distance': '115',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657684,23.641020;113.657623,23.641125;113.657524,23.641245;113.657440,23.641363;113.657059,23.641901',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行68米左转',\n",
       "        'road': [],\n",
       "        'distance': '68',\n",
       "        'duration': [],\n",
       "        'polyline': '113.657059,23.641901;113.656929,23.641827;113.656876,23.641819;113.656738,23.641840;113.656609,23.641914;113.656433,23.641922',\n",
       "        'action': '左转',\n",
       "        'assistant_action': []},\n",
       "       {'instruction': '步行114米',\n",
       "        'road': [],\n",
       "        'distance': '114',\n",
       "        'duration': [],\n",
       "        'polyline': '113.656433,23.641922;113.656425,23.641870;113.656395,23.641819;113.656273,23.641745;113.656174,23.641714;113.656013,23.641684;113.655876,23.641676;113.655418,23.641701',\n",
       "        'action': [],\n",
       "        'assistant_action': []}]},\n",
       "     'bus': {'buslines': []},\n",
       "     'entrance': [],\n",
       "     'exit': [],\n",
       "     'railway': {'via_stops': [], 'alters': [], 'spaces': []}}]}]}"
      ]
     },
     "execution_count": 208,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bus(chen_key,起始点,目的地,mycity)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 应用场景\n",
    "公交路径规划返回公交换乘信息列表中有各换乘方案明确的换乘价格、时间、步行距离等进行对比，可计算出最便宜的、最快的换乘方案"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 驾车\n",
    "* 1、url：https://restapi.amap.com/v3/direction/driving?parameters\n",
    "* 2、requests.get()\n",
    "* 3、参数  \n",
    "    A.必选：key，origin，destination  \n",
    "    B.可选：originid，destinationid，origintype，destinationtype，strategy（默认值0），waypoints，avoidpolygons，avoidroad，province，number，cartype（默认0），roadaggregation（默认false），nosteps（默认0），sig，output（默认JSON）,callback,extensions(默认base)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 210,
   "metadata": {},
   "outputs": [],
   "source": [
    "#驾车\n",
    "def drive(key,origin,destination,originid=None,destinationid=None,origintype=None,destinationtype=None,strategy=0,waypoints=None,avoidpolygons=None,avoidroad=None,province=None,number=None,cartype=0,roadaggregation=\"false\",nosteps=0,sig=None,output=\"JSON\",callback=None,extensions=\"base\"):\n",
    "    \"\"\"获取驾车路径规划 \n",
    "    可以规划以小客车、轿车通勤出行的方案，并且返回通勤方案的数据。\"\"\"\n",
    "    url = \"https://restapi.amap.com/v3/direction/driving?parameters\"\n",
    "    params = {\n",
    "    \"key\":key,\n",
    "    \"origin\":origin,\n",
    "    \"destination\":destination,\n",
    "    \"originid\":originid,\n",
    "    \"destinationid\":destinationid,\n",
    "    \"strategy\":strategy,\n",
    "    \"waypoints\":waypoints,\n",
    "    \"avoidpolygons\":avoidpolygons,\n",
    "    \"avoidroad\":avoidroad,\n",
    "    \"province\":province,\n",
    "    \"number\":number,\n",
    "    \"cartype\":cartype,\n",
    "    \"roadaggregation\":roadaggregation,\n",
    "    \"nosteps\":nosteps,\n",
    "    \"sig\":sig,\n",
    "    \"output\":output,\n",
    "    \"callback\":callback,\n",
    "    \"extensions\":extensions\n",
    "    }\n",
    "    r = requests.get(url,params)\n",
    "    results = r.json()['route']['paths']\n",
    "    return results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 211,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'distance': '6382',\n",
       "  'duration': '957',\n",
       "  'strategy': '速度最快',\n",
       "  'tolls': '0',\n",
       "  'toll_distance': '0',\n",
       "  'steps': [{'instruction': '向北行驶122米向左前方行驶',\n",
       "    'orientation': '北',\n",
       "    'distance': '122',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '30',\n",
       "    'polyline': '113.679596,23.632574;113.679596,23.632856;113.679592,23.633173;113.679596,23.633251;113.679627,23.63365;113.679648,23.633689',\n",
       "    'action': '向左前方行驶',\n",
       "    'assistant_action': []},\n",
       "   {'instruction': '沿博学路向北行驶79米向左前方行驶',\n",
       "    'orientation': '北',\n",
       "    'road': '博学路',\n",
       "    'distance': '79',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '21',\n",
       "    'polyline': '113.679648,23.633689;113.679549,23.633967;113.679375,23.634358',\n",
       "    'action': '向左前方行驶',\n",
       "    'assistant_action': []},\n",
       "   {'instruction': '沿博学路向西北行驶118米左转',\n",
       "    'orientation': '西北',\n",
       "    'road': '博学路',\n",
       "    'distance': '118',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '30',\n",
       "    'polyline': '113.679375,23.634358;113.679249,23.634479;113.678932,23.634761;113.678711,23.634918;113.678628,23.63497;113.678594,23.63503;113.678555,23.635109',\n",
       "    'action': '左转',\n",
       "    'assistant_action': []},\n",
       "   {'instruction': '沿博学路向西行驶163米右转',\n",
       "    'orientation': '西',\n",
       "    'road': '博学路',\n",
       "    'distance': '163',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '34',\n",
       "    'polyline': '113.678555,23.635109;113.677856,23.635087;113.677613,23.63503;113.67753,23.634991;113.677326,23.634852;113.677083,23.634661',\n",
       "    'action': '右转',\n",
       "    'assistant_action': []},\n",
       "   {'instruction': '沿博学路向西行驶33米右转',\n",
       "    'orientation': '西',\n",
       "    'road': '博学路',\n",
       "    'distance': '33',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '12',\n",
       "    'polyline': '113.677083,23.634661;113.677027,23.634701;113.676918,23.634718;113.676849,23.634701;113.676788,23.634657',\n",
       "    'action': '右转',\n",
       "    'assistant_action': []},\n",
       "   {'instruction': '沿中山路向西北行驶1.3千米右转',\n",
       "    'orientation': '西北',\n",
       "    'road': '中山路',\n",
       "    'distance': '1265',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '274',\n",
       "    'polyline': '113.676788,23.634657;113.675265,23.636128;113.675152,23.636263;113.675026,23.636467;113.67497,23.636567;113.674957,23.636701;113.674957,23.636845;113.674991,23.636997;113.675378,23.637886;113.67543,23.638043;113.675521,23.638659;113.67553,23.638997;113.675508,23.639132;113.675447,23.63931;113.67533,23.639583;113.675104,23.640035;113.675,23.640187;113.67431,23.641024;113.673355,23.64214;113.672977,23.642535;113.672934,23.642578;113.67217,23.643307;113.671428,23.644045',\n",
       "    'action': '右转',\n",
       "    'assistant_action': []},\n",
       "   {'instruction': '沿温泉大道向东北行驶605米左转调头',\n",
       "    'orientation': '东北',\n",
       "    'road': '温泉大道',\n",
       "    'distance': '605',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '66',\n",
       "    'polyline': '113.671428,23.644045;113.671636,23.644162;113.673103,23.64497;113.673945,23.645425;113.674366,23.645651;113.67546,23.646276;113.675968,23.646636;113.676411,23.647018',\n",
       "    'action': '左转调头',\n",
       "    'assistant_action': []},\n",
       "   {'instruction': '沿温泉大道向西南行驶2.4千米向右前方行驶进入右转专用道',\n",
       "    'orientation': '西南',\n",
       "    'road': '温泉大道',\n",
       "    'distance': '2357',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '139',\n",
       "    'polyline': '113.676367,23.647088;113.675964,23.646745;113.675734,23.646567;113.675464,23.646385;113.675095,23.646172;113.673003,23.645004;113.669961,23.643329;113.669162,23.642882;113.668776,23.642674;113.668598,23.642578;113.667001,23.641693;113.666141,23.641172;113.665317,23.640564;113.665252,23.640512;113.665017,23.640299;113.664774,23.640065;113.664549,23.639813;113.66441,23.639661;113.664201,23.639401;113.663928,23.639019;113.663576,23.638451;113.663359,23.638021;113.662322,23.635933;113.661949,23.635182;113.661454,23.634266;113.661224,23.633898;113.660842,23.633381;113.660686,23.63319;113.660252,23.632704',\n",
       "    'action': '向右前方行驶',\n",
       "    'assistant_action': '进入右转专用道'},\n",
       "   {'instruction': '沿景泉大道向西行驶124米右转',\n",
       "    'orientation': '西',\n",
       "    'road': '景泉大道',\n",
       "    'distance': '124',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '19',\n",
       "    'polyline': '113.660252,23.632704;113.660056,23.632613;113.659887,23.632569;113.659666,23.632609;113.659566,23.632648;113.659479,23.632695;113.659379,23.632786;113.659232,23.632986',\n",
       "    'action': '右转',\n",
       "    'assistant_action': []},\n",
       "   {'instruction': '沿景泉大道向北行驶755米进入环岛',\n",
       "    'orientation': '北',\n",
       "    'road': '景泉大道',\n",
       "    'distance': '755',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '60',\n",
       "    'polyline': '113.659232,23.632986;113.659258,23.633407;113.659232,23.633767;113.659188,23.634154;113.658958,23.636133;113.658572,23.639327;113.658568,23.639527;113.658659,23.63977',\n",
       "    'action': '进入环岛',\n",
       "    'assistant_action': []},\n",
       "   {'instruction': '向北行驶53米离开环岛',\n",
       "    'orientation': '北',\n",
       "    'distance': '53',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '22',\n",
       "    'polyline': '113.658659,23.63977;113.658733,23.639861;113.65875,23.639957;113.658707,23.640035;113.65862,23.640091;113.658524,23.640104',\n",
       "    'action': '离开环岛',\n",
       "    'assistant_action': []},\n",
       "   {'instruction': '沿温泉东路向西北行驶247米左转进入右侧道路',\n",
       "    'orientation': '西北',\n",
       "    'road': '温泉东路',\n",
       "    'distance': '247',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '41',\n",
       "    'polyline': '113.658524,23.640104;113.658129,23.640421;113.65803,23.640543;113.657734,23.640933;113.657617,23.641124;113.657522,23.641246;113.657435,23.641363;113.657053,23.641901',\n",
       "    'action': '左转',\n",
       "    'assistant_action': '进入右侧道路'},\n",
       "   {'instruction': '向西行驶68米右转',\n",
       "    'orientation': '西',\n",
       "    'distance': '68',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '28',\n",
       "    'polyline': '113.657053,23.641901;113.656927,23.641823;113.656871,23.641814;113.656736,23.64184;113.656606,23.641914;113.656432,23.641923',\n",
       "    'action': '右转',\n",
       "    'assistant_action': []},\n",
       "   {'instruction': '向西行驶249米左转',\n",
       "    'orientation': '西',\n",
       "    'distance': '249',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '139',\n",
       "    'polyline': '113.656432,23.641923;113.656385,23.642014;113.656207,23.642131;113.656003,23.642231;113.65589,23.642261;113.654701,23.642352;113.654592,23.642331;113.654384,23.64224;113.654236,23.642161;113.654201,23.642114',\n",
       "    'action': '左转',\n",
       "    'assistant_action': []},\n",
       "   {'instruction': '向南行驶14米靠右',\n",
       "    'orientation': '南',\n",
       "    'distance': '14',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '5',\n",
       "    'polyline': '113.654201,23.642114;113.654188,23.642049;113.654223,23.641997',\n",
       "    'action': '靠右',\n",
       "    'assistant_action': []},\n",
       "   {'instruction': '向东行驶130米到达目的地',\n",
       "    'orientation': '东',\n",
       "    'distance': '130',\n",
       "    'tolls': '0',\n",
       "    'toll_distance': '0',\n",
       "    'toll_road': [],\n",
       "    'duration': '37',\n",
       "    'polyline': '113.654223,23.641997;113.654453,23.641823;113.654605,23.641766;113.655243,23.641714;113.655417,23.641701',\n",
       "    'action': [],\n",
       "    'assistant_action': '到达目的地'}],\n",
       "  'restriction': '0',\n",
       "  'traffic_lights': '1'}]"
      ]
     },
     "execution_count": 211,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "drive(chen_key,起始点,目的地)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 应用场景\n",
    "驾车路径规划返回的驾车方案有多个方案的红路灯个数、行驶时间、道路收费、限行等对比，可计算出驾车出行最快捷、收费最少的路径，并进行导航"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 行政区查询\n",
    "* 1、url：https://restapi.amap.com/v3/config/district?parameters\n",
    "* 2、requests.get()\n",
    "* 3、参数  \n",
    "    A.必选：key  \n",
    "    B.可选：keywords，subdistrict（默认值1），page（默认值1），offset（默认值20），extensions（默认值base），filter，callback,output(默认JSON)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 213,
   "metadata": {},
   "outputs": [],
   "source": [
    "#数据准备\n",
    "mykeywords = \"广州\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 214,
   "metadata": {},
   "outputs": [],
   "source": [
    "def district(key,keywords,subdistrict=1,page=1,offset=20,extensions=\"base\",filter=None,callback=None,output=\"JSON\"):\n",
    "    \"\"\"行政区域查询\n",
    "    根据用户输入的搜索条件可以帮助用户快速的查找特定的行政区域信息\"\"\"\n",
    "    url = \"https://restapi.amap.com/v3/config/district?parameters\"\n",
    "    params = {\n",
    "    \"key\":key,\n",
    "    \"keywords\":keywords,\n",
    "    \"subdistrict\":subdistrict,\n",
    "    \"page\":page,\n",
    "    \"offset\":offset,\n",
    "    \"extensions\":extensions,\n",
    "    \"filter\":filter,\n",
    "    \"callback\":callback,\n",
    "    \"output\":output\n",
    "    }\n",
    "    r = requests.get(url,params)\n",
    "    results = r.json()['districts']\n",
    "    return results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 215,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'citycode': '020',\n",
       "  'adcode': '440100',\n",
       "  'name': '广州市',\n",
       "  'center': '113.280637,23.125178',\n",
       "  'level': 'city',\n",
       "  'districts': [{'citycode': '020',\n",
       "    'adcode': '440117',\n",
       "    'name': '从化区',\n",
       "    'center': '113.587386,23.545283',\n",
       "    'level': 'district',\n",
       "    'districts': []},\n",
       "   {'citycode': '020',\n",
       "    'adcode': '440114',\n",
       "    'name': '花都区',\n",
       "    'center': '113.211184,23.39205',\n",
       "    'level': 'district',\n",
       "    'districts': []},\n",
       "   {'citycode': '020',\n",
       "    'adcode': '440115',\n",
       "    'name': '南沙区',\n",
       "    'center': '113.53738,22.794531',\n",
       "    'level': 'district',\n",
       "    'districts': []},\n",
       "   {'citycode': '020',\n",
       "    'adcode': '440113',\n",
       "    'name': '番禺区',\n",
       "    'center': '113.364619,22.938582',\n",
       "    'level': 'district',\n",
       "    'districts': []},\n",
       "   {'citycode': '020',\n",
       "    'adcode': '440111',\n",
       "    'name': '白云区',\n",
       "    'center': '113.262831,23.162281',\n",
       "    'level': 'district',\n",
       "    'districts': []},\n",
       "   {'citycode': '020',\n",
       "    'adcode': '440105',\n",
       "    'name': '海珠区',\n",
       "    'center': '113.262008,23.103131',\n",
       "    'level': 'district',\n",
       "    'districts': []},\n",
       "   {'citycode': '020',\n",
       "    'adcode': '440103',\n",
       "    'name': '荔湾区',\n",
       "    'center': '113.243038,23.124943',\n",
       "    'level': 'district',\n",
       "    'districts': []},\n",
       "   {'citycode': '020',\n",
       "    'adcode': '440118',\n",
       "    'name': '增城区',\n",
       "    'center': '113.829579,23.290497',\n",
       "    'level': 'district',\n",
       "    'districts': []},\n",
       "   {'citycode': '020',\n",
       "    'adcode': '440104',\n",
       "    'name': '越秀区',\n",
       "    'center': '113.280714,23.125624',\n",
       "    'level': 'district',\n",
       "    'districts': []},\n",
       "   {'citycode': '020',\n",
       "    'adcode': '440106',\n",
       "    'name': '天河区',\n",
       "    'center': '113.335367,23.13559',\n",
       "    'level': 'district',\n",
       "    'districts': []},\n",
       "   {'citycode': '020',\n",
       "    'adcode': '440112',\n",
       "    'name': '黄埔区',\n",
       "    'center': '113.450761,23.103239',\n",
       "    'level': 'district',\n",
       "    'districts': []}]}]"
      ]
     },
     "execution_count": 215,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "district(chen_key,mykeywords)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 应用场景\n",
    "行政区域查询返回的结果中可以得出下级行政区及区域编码，可以应用于快递包裹派送服务，使派送更加精准、快捷"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 搜索PIO\n",
    "### 关键字搜索\n",
    "* 1、url：https://restapi.amap.com/v3/place/text?parameters\n",
    "* 2、requests.get()\n",
    "* 3、参数  \n",
    "    A.必选：key，keywords，types  \n",
    "    B.可选：city，citylimit（默认值false），children（默认值0），offset（默认值20），page（默认值1），extensions（默认值base）,sig,callback,output（默认JSON）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [],
   "source": [
    "#数据准备\n",
    "a_keywords = \"中山大学南方学院\"\n",
    "a_types = \"高等院校\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 223,
   "metadata": {},
   "outputs": [],
   "source": [
    "#关键字搜索\n",
    "def text(key,keywords,types,city=None,citylimit=\"base\",children=0,offset=20,page=1,extensions=\"base\",sig=None,callback=None,output=\"JSON\"):\n",
    "    \"\"\"关键字搜索\n",
    "    通过用POI的关键字进行条件搜索，例如：肯德基、朝阳公园等；同时支持设置POI类型搜索，例如：银行\"\"\"\n",
    "    url = \"https://restapi.amap.com/v3/place/text?parameters\"\n",
    "    params = {\n",
    "    \"key\":key,\n",
    "    \"keywords\":keywords,\n",
    "    \"types\":types,\n",
    "    \"city\":city,\n",
    "    \"citylimit\":citylimit,\n",
    "    \"children\":children,\n",
    "    \"offset\":offset,\n",
    "    \"page\":page,\n",
    "    \"extensions\":extensions,\n",
    "    \"sig\":sig,\n",
    "    \"callback\":callback,\n",
    "    \"output\":output\n",
    "   \n",
    "    }\n",
    "    r = requests.get(url,params)\n",
    "    results = r.json()\n",
    "    return results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 224,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'suggestion': {'keywords': [], 'cities': []},\n",
       " 'count': '6',\n",
       " 'infocode': '10000',\n",
       " 'pois': [{'parent': [],\n",
       "   'address': '温泉大道882号',\n",
       "   'distance': [],\n",
       "   'biz_ext': [],\n",
       "   'pname': '广东省',\n",
       "   'importance': [],\n",
       "   'biz_type': [],\n",
       "   'cityname': '广州市',\n",
       "   'type': '科教文化服务;学校;高等院校',\n",
       "   'photos': [],\n",
       "   'typecode': '141201',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'adname': '从化区',\n",
       "   'name': '中山大学南方学院',\n",
       "   'location': '113.679262,23.632583',\n",
       "   'tel': '020-61787331',\n",
       "   'shopid': [],\n",
       "   'id': 'B00140MR9A'},\n",
       "  {'parent': [],\n",
       "   'address': '温泉镇',\n",
       "   'distance': [],\n",
       "   'biz_ext': [],\n",
       "   'pname': '广东省',\n",
       "   'importance': [],\n",
       "   'biz_type': [],\n",
       "   'cityname': '广州市',\n",
       "   'type': '科教文化服务;学校;高等院校',\n",
       "   'photos': [],\n",
       "   'typecode': '141201',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'adname': '从化区',\n",
       "   'name': '中山大学南方学院',\n",
       "   'location': '113.671493,23.643831',\n",
       "   'tel': [],\n",
       "   'shopid': [],\n",
       "   'id': 'B0FFMCZOK0'},\n",
       "  {'parent': 'B00140MR9A',\n",
       "   'address': '博学路7',\n",
       "   'distance': [],\n",
       "   'biz_ext': [],\n",
       "   'pname': '广东省',\n",
       "   'importance': [],\n",
       "   'biz_type': [],\n",
       "   'cityname': '广州市',\n",
       "   'type': '科教文化服务;学校;高等院校',\n",
       "   'photos': [],\n",
       "   'typecode': '141201',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': '309',\n",
       "   'adname': '从化区',\n",
       "   'name': '中山大学南方学院教学楼7号',\n",
       "   'location': '113.678600,23.633330',\n",
       "   'tel': [],\n",
       "   'shopid': [],\n",
       "   'id': 'B00141TQGR'},\n",
       "  {'parent': 'B00140MR9A',\n",
       "   'address': '南方学院东北',\n",
       "   'distance': [],\n",
       "   'biz_ext': [],\n",
       "   'pname': '广东省',\n",
       "   'importance': [],\n",
       "   'biz_type': [],\n",
       "   'cityname': '广州市',\n",
       "   'type': '科教文化服务;学校;高等院校',\n",
       "   'photos': [],\n",
       "   'typecode': '141201',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': '309',\n",
       "   'adname': '从化区',\n",
       "   'name': '中山大学南方学院12BLOCK',\n",
       "   'location': '113.682608,23.636598',\n",
       "   'tel': [],\n",
       "   'shopid': [],\n",
       "   'id': 'B0FFLJV95W'},\n",
       "  {'parent': 'B00140MR9A',\n",
       "   'address': '博学路7号附近',\n",
       "   'distance': [],\n",
       "   'biz_ext': [],\n",
       "   'pname': '广东省',\n",
       "   'importance': [],\n",
       "   'biz_type': [],\n",
       "   'cityname': '广州市',\n",
       "   'type': '科教文化服务;学校;高等院校',\n",
       "   'photos': [],\n",
       "   'typecode': '141201',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': '309',\n",
       "   'adname': '从化区',\n",
       "   'name': '中山大学南方学院惟贤门',\n",
       "   'location': '113.678437,23.633721',\n",
       "   'tel': [],\n",
       "   'shopid': [],\n",
       "   'id': 'B0FFKERBQZ'},\n",
       "  {'parent': [],\n",
       "   'address': [],\n",
       "   'distance': [],\n",
       "   'biz_ext': [],\n",
       "   'pname': '广东省',\n",
       "   'importance': [],\n",
       "   'biz_type': [],\n",
       "   'cityname': '广州市',\n",
       "   'type': '科教文化服务;学校;高等院校',\n",
       "   'photos': [],\n",
       "   'typecode': '141201',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'adname': '从化区',\n",
       "   'name': '中山大学南方学院教学楼1号',\n",
       "   'location': '113.677077,23.631783',\n",
       "   'tel': [],\n",
       "   'shopid': [],\n",
       "   'id': 'B0G3ARGF5Y'}],\n",
       " 'status': '1',\n",
       " 'info': 'OK'}"
      ]
     },
     "execution_count": 224,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text(chen_key,a_keywords,a_types)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 应用场景\n",
    "关键字搜索通过关键字可以精确返回对应poi类型地址信息，可以在地图中应用于寻找公园、银行、学校等，并附有具体地理信息"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 周边搜索\n",
    "* 1、url：https://restapi.amap.com/v3/place/around?parameters \n",
    "* 2、requests.get()\n",
    "* 3、参数  \n",
    "    A.必选：key，location  \n",
    "    B.可选：keywords，types，city，radius（默认值3000），sortrule（默认值distance），offset（默认值20），page（默认值1），extensions（默认值base）,sig,callback,output(默认JSON)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 228,
   "metadata": {},
   "outputs": [],
   "source": [
    "#周边搜索\n",
    "def around(key,location,keywords=None,types=None,city=None,radius=3000,sortrule=\"distance\",offset=20,page=1,extensions=\"base\",sig=None,callback=None,output=\"JSON\"):\n",
    "    \"\"\"周边搜索\n",
    "    在用户传入经纬度坐标点附近，在设定的范围内，按照关键字或POI类型搜索\"\"\"\n",
    "    url = \"https://restapi.amap.com/v3/place/around?parameters\"\n",
    "    params = {\n",
    "    \"key\":key,\n",
    "    \"location\":location,\n",
    "    \"keywords\":keywords,\n",
    "    \"types\":types,\n",
    "    \"city\":city,\n",
    "    \"radius\":radius,\n",
    "    \"sortrule\":sortrule,\n",
    "    \"offset\":offset,\n",
    "    \"page\":page,\n",
    "    \"extensions\":extensions,\n",
    "    \"sig\":sig,\n",
    "    \"callback\":callback,\n",
    "    \"output\":output\n",
    "    }\n",
    "    r = requests.get(url,params)\n",
    "    results = r.json()\n",
    "    return results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 229,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'suggestion': {'keywords': [], 'cities': []},\n",
       " 'count': '838',\n",
       " 'infocode': '10000',\n",
       " 'pois': [{'parent': [],\n",
       "   'address': '温泉镇笃行路20、22、24号中山大学南方学院',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': [],\n",
       "   'type': '生活服务;共享设备;充电宝',\n",
       "   'photos': [],\n",
       "   'typecode': '072101',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '街电(榴芒一族中山大学南方学院店)',\n",
       "   'location': '113.679287,23.632575',\n",
       "   'tel': [],\n",
       "   'shopid': [],\n",
       "   'id': 'B0FFLB846S'},\n",
       "  {'parent': [],\n",
       "   'address': '从化温泉镇中山大学南方学院博学路6号',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;中餐厅;特色/地方风味餐厅',\n",
       "   'photos': [],\n",
       "   'typecode': '050118',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '爽爽石磨肠粉',\n",
       "   'location': '113.679287,23.632575',\n",
       "   'tel': '18218913303',\n",
       "   'shopid': [],\n",
       "   'id': 'B0FFKX3T5Y'},\n",
       "  {'parent': [],\n",
       "   'address': '温泉镇中山大学南方学院明辨路2号二、三层',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;餐饮相关场所;餐饮相关',\n",
       "   'photos': [],\n",
       "   'typecode': '050000',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '避风塘',\n",
       "   'location': '113.679286,23.632574',\n",
       "   'tel': [],\n",
       "   'shopid': [],\n",
       "   'id': 'B0FFKT2R96'},\n",
       "  {'parent': [],\n",
       "   'address': '温泉镇中山大学南方学院明辨路2号二、三层',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;餐饮相关场所;餐饮相关',\n",
       "   'photos': [],\n",
       "   'typecode': '050000',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': 'slim tea',\n",
       "   'location': '113.679286,23.632574',\n",
       "   'tel': '18944690066',\n",
       "   'shopid': [],\n",
       "   'id': 'B0FFKSLFAN'},\n",
       "  {'parent': [],\n",
       "   'address': '温泉镇中山大学南方学院后门润泰超市一楼05号商铺',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;中餐厅;特色/地方风味餐厅',\n",
       "   'photos': [],\n",
       "   'typecode': '050118',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '劲酷烤吧',\n",
       "   'location': '113.679286,23.632573',\n",
       "   'tel': '13719231627',\n",
       "   'shopid': [],\n",
       "   'id': 'B0G3AYBO5X'},\n",
       "  {'parent': [],\n",
       "   'address': '温泉镇中山大学南方学院后门润泰超市一楼05号商铺',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;中餐厅;广东菜(粤菜)',\n",
       "   'photos': [],\n",
       "   'typecode': '050103',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '东记乡村美食',\n",
       "   'location': '113.679286,23.632573',\n",
       "   'tel': '13922398107',\n",
       "   'shopid': [],\n",
       "   'id': 'B0G3APADKJ'},\n",
       "  {'parent': [],\n",
       "   'address': '温泉镇中山大学南方学院后门润泰超市一楼05号商铺',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;快餐厅;快餐厅',\n",
       "   'photos': [],\n",
       "   'typecode': '050300',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '北方饺子馆',\n",
       "   'location': '113.679286,23.632573',\n",
       "   'tel': '13434241448',\n",
       "   'shopid': [],\n",
       "   'id': 'B0G2Z7IX80'},\n",
       "  {'parent': [],\n",
       "   'address': '温泉镇中山大学南方学院后门润泰超市一楼05号商铺',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;餐饮相关场所;餐饮相关',\n",
       "   'photos': [],\n",
       "   'typecode': '050000',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '第1烤场',\n",
       "   'location': '113.679286,23.632573',\n",
       "   'tel': '13538825321',\n",
       "   'shopid': [],\n",
       "   'id': 'B0G2K6PX0X'},\n",
       "  {'parent': [],\n",
       "   'address': '温泉镇中山大学南方学院后门润泰超市一楼05号商铺',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;餐饮相关场所;餐饮相关',\n",
       "   'photos': [],\n",
       "   'typecode': '050000',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '叶龙老武汉烧烤',\n",
       "   'location': '113.679286,23.632573',\n",
       "   'tel': '15918718710;13125030232',\n",
       "   'shopid': [],\n",
       "   'id': 'B0G1393J7X'},\n",
       "  {'parent': [],\n",
       "   'address': '从化温泉镇中山大学南方学院明辩路2号',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;餐饮相关场所;餐饮相关',\n",
       "   'photos': [],\n",
       "   'typecode': '050000',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '网红小串店',\n",
       "   'location': '113.679286,23.632573',\n",
       "   'tel': '13802426981',\n",
       "   'shopid': [],\n",
       "   'id': 'B0FFLNRH1K'},\n",
       "  {'parent': [],\n",
       "   'address': '温泉镇中山大学南方学院后门润泰超市一楼05号商铺',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;餐饮相关场所;餐饮相关',\n",
       "   'photos': [],\n",
       "   'typecode': '050000',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '过气轻食屋',\n",
       "   'location': '113.679286,23.632573',\n",
       "   'tel': '13049636920',\n",
       "   'shopid': [],\n",
       "   'id': 'B0FFKTDMOI'},\n",
       "  {'parent': [],\n",
       "   'address': '温泉镇中山大学南方学院后门润泰超市一楼05号商铺',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;餐饮相关场所;餐饮相关',\n",
       "   'photos': [],\n",
       "   'typecode': '050000',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '莫凡烧烤',\n",
       "   'location': '113.679286,23.632573',\n",
       "   'tel': '13929768267',\n",
       "   'shopid': [],\n",
       "   'id': 'B0FFKT4WNY'},\n",
       "  {'parent': [],\n",
       "   'address': '温泉大道882号旁润泰超市一楼商铺',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;冷饮店;冷饮店',\n",
       "   'photos': [],\n",
       "   'typecode': '050700',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': 'LV柠檬茶',\n",
       "   'location': '113.679286,23.632573',\n",
       "   'tel': '15018428578',\n",
       "   'shopid': [],\n",
       "   'id': 'B0FFIIQNQ7'},\n",
       "  {'parent': [],\n",
       "   'address': '温泉镇中山大学南方学院后门润泰超市一楼05号商铺',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;甜品店;甜品店',\n",
       "   'photos': [],\n",
       "   'typecode': '050900',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '味美轩(中大店)',\n",
       "   'location': '113.679286,23.632571',\n",
       "   'tel': '15915874513',\n",
       "   'shopid': [],\n",
       "   'id': 'B0G2T96S9V'},\n",
       "  {'parent': [],\n",
       "   'address': '中山大学南方学院',\n",
       "   'distance': '0',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;中餐厅;四川菜(川菜)',\n",
       "   'photos': [],\n",
       "   'typecode': '050102',\n",
       "   'shopinfo': '1',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '重庆湖边纸包鱼',\n",
       "   'location': '113.679871,23.630292',\n",
       "   'tel': '13924024938',\n",
       "   'shopid': [],\n",
       "   'id': 'B0FFL7NUA2'},\n",
       "  {'parent': [],\n",
       "   'address': '博学路中山大学南方学院后门润泰超市首层23号',\n",
       "   'distance': '1',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;快餐厅;快餐厅',\n",
       "   'photos': [],\n",
       "   'typecode': '050300',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '我家厨房',\n",
       "   'location': '113.679289,23.632563',\n",
       "   'tel': [],\n",
       "   'shopid': [],\n",
       "   'id': 'B0FFK28XPU'},\n",
       "  {'parent': [],\n",
       "   'address': '温泉大道882号',\n",
       "   'distance': '2',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': [],\n",
       "   'type': '生活服务;共享设备;充电宝',\n",
       "   'photos': [],\n",
       "   'typecode': '072101',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '怪兽充电(中山大学南方学院)',\n",
       "   'location': '113.679262,23.632583',\n",
       "   'tel': [],\n",
       "   'shopid': [],\n",
       "   'id': 'B0FFLLU813'},\n",
       "  {'parent': [],\n",
       "   'address': '温泉镇博学路中山大学南方学院后门润泰超市一楼05号商铺',\n",
       "   'distance': '9',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;外国餐厅;日本料理',\n",
       "   'photos': [],\n",
       "   'typecode': '050202',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '井禾寿司',\n",
       "   'location': '113.679193,23.632552',\n",
       "   'tel': '13789117723',\n",
       "   'shopid': [],\n",
       "   'id': 'B0G14PDQVA'},\n",
       "  {'parent': [],\n",
       "   'address': '中山大学南方学院',\n",
       "   'distance': '12',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;外国餐厅;西餐厅(综合风味)',\n",
       "   'photos': [],\n",
       "   'typecode': '050201',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': 'Uni-hotel西餐',\n",
       "   'location': '113.679224,23.632671',\n",
       "   'tel': [],\n",
       "   'shopid': [],\n",
       "   'id': 'B0GR3OMDZ2'},\n",
       "  {'parent': [],\n",
       "   'address': '从化温泉镇中山大学南方学院明辩路2号',\n",
       "   'distance': '16',\n",
       "   'biz_ext': [],\n",
       "   'importance': [],\n",
       "   'biz_type': 'diner',\n",
       "   'type': '餐饮服务;中餐厅;广东菜(粤菜)',\n",
       "   'photos': [],\n",
       "   'typecode': '050103',\n",
       "   'shopinfo': '0',\n",
       "   'poiweight': [],\n",
       "   'childtype': [],\n",
       "   'name': '耀记美食',\n",
       "   'location': '113.679405,23.632673',\n",
       "   'tel': '18816801934',\n",
       "   'shopid': [],\n",
       "   'id': 'B0GRGOTLSL'}],\n",
       " 'status': '1',\n",
       " 'info': 'OK'}"
      ]
     },
     "execution_count": 229,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "around(chen_key,起始点)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 应用场景\n",
    "定位用户所在地，以经纬度输入，在设定的范围内，用户可以以关键字或poi类型搜索得出周边餐厅、医院等"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## IP定位\n",
    "* 1、url：https://restapi.amap.com/v3/ip?parameters\n",
    "* 2、requests.get()\n",
    "* 3、参数  \n",
    "    A.必选：key  \n",
    "    B.可选：ip,sig,output(默认JSON)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 231,
   "metadata": {},
   "outputs": [],
   "source": [
    "def ip(key,ip=None,sig=None,output=\"JSON\"):\n",
    "    \"\"\"ip定位\n",
    "    根据用户输入的IP地址，能够快速的帮用户定位IP的所在位置。\"\"\"\n",
    "    url = \"https://restapi.amap.com/v3/ip?parameters\"\n",
    "    params = {\n",
    "    \"key\":key,\n",
    "    \"ip\":ip,\n",
    "    \"sig\":sig,\n",
    "    \"output\":output\n",
    "    }\n",
    "    r = requests.get(url,params)\n",
    "    results = r.json()\n",
    "    return results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 232,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'province': '广东省',\n",
       " 'city': '广州市',\n",
       " 'adcode': '440100',\n",
       " 'rectangle': '113.1017375,22.93212254;113.6770499,23.3809537'}"
      ]
     },
     "execution_count": 232,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ip(chen_key)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 应用场景\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 静态地图\n",
    "* 1、url：https://restapi.amap.com/v3/staticmap?parameters\n",
    "* 2、requests.get()\n",
    "* 3、参数  \n",
    "    A.必选：key，location（部分条件必填），zoom  \n",
    "    B.可选：size（默认值400 * 400），scale（默认值1），markers，labels，paths，traffic"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = \"https://restapi.amap.com/v3/staticmap?parameters\"\n",
    "params = {\n",
    "    \"key\":chen_key,\n",
    "    \"location\":起始点,\n",
    "    \"zoom\":[1,17]\n",
    "}\n",
    "r = requests.get(url,params)\n",
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [
    {
     "ename": "JSONDecodeError",
     "evalue": "Expecting value: line 1 column 1 (char 0)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mJSONDecodeError\u001b[0m                           Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-93-52b7ec8d97cc>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjson\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\requests\\models.py\u001b[0m in \u001b[0;36mjson\u001b[1;34m(self, **kwargs)\u001b[0m\n\u001b[0;32m    896\u001b[0m                     \u001b[1;31m# used.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    897\u001b[0m                     \u001b[1;32mpass\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 898\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0mcomplexjson\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloads\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtext\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    899\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    900\u001b[0m     \u001b[1;33m@\u001b[0m\u001b[0mproperty\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\anaconda3\\lib\\json\\__init__.py\u001b[0m in \u001b[0;36mloads\u001b[1;34m(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)\u001b[0m\n\u001b[0;32m    355\u001b[0m             \u001b[0mparse_int\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mparse_float\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m \u001b[1;32mand\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    356\u001b[0m             parse_constant is None and object_pairs_hook is None and not kw):\n\u001b[1;32m--> 357\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0m_default_decoder\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    358\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0mcls\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    359\u001b[0m         \u001b[0mcls\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mJSONDecoder\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\anaconda3\\lib\\json\\decoder.py\u001b[0m in \u001b[0;36mdecode\u001b[1;34m(self, s, _w)\u001b[0m\n\u001b[0;32m    335\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    336\u001b[0m         \"\"\"\n\u001b[1;32m--> 337\u001b[1;33m         \u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mraw_decode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0midx\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0m_w\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    338\u001b[0m         \u001b[0mend\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_w\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    339\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mend\u001b[0m \u001b[1;33m!=\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\anaconda3\\lib\\json\\decoder.py\u001b[0m in \u001b[0;36mraw_decode\u001b[1;34m(self, s, idx)\u001b[0m\n\u001b[0;32m    353\u001b[0m             \u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mscan_once\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0midx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    354\u001b[0m         \u001b[1;32mexcept\u001b[0m \u001b[0mStopIteration\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 355\u001b[1;33m             \u001b[1;32mraise\u001b[0m \u001b[0mJSONDecodeError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Expecting value\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0ms\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    356\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mJSONDecodeError\u001b[0m: Expecting value: line 1 column 1 (char 0)"
     ]
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 坐标转换\n",
    "* 1、url：https://restapi.amap.com/v3/assistant/coordinate/convert?parameters\n",
    "* 2、requests.get()\n",
    "* 3、参数  \n",
    "    A.必选：key，locations  \n",
    "    B.可选：coordsys（默认值autonavi）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = \"https://restapi.amap.com/v3/assistant/coordinate/convert?parameters\"\n",
    "params = {\n",
    "    \"key\":chen_key,\n",
    "    \"locations\":起始点\n",
    "}\n",
    "r = requests.get(url,params)\n",
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'ok',\n",
       " 'infocode': '10000',\n",
       " 'locations': '113.679287,23.632575'}"
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 天气查询\n",
    "* 1、url：https://restapi.amap.com/v3/weather/weatherInfo?parameters\n",
    "* 2、requests.get()\n",
    "* 3、参数  \n",
    "    A.必选：key，city  \n",
    "    B.可选：extensions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {},
   "outputs": [],
   "source": [
    "#数据准备\n",
    "t_city = \"440117\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = \"https://restapi.amap.com/v3/weather/weatherInfo?parameters\"\n",
    "params = {\n",
    "    \"key\":chen_key,\n",
    "    \"city\":t_city\n",
    "}\n",
    "r = requests.get(url,params)\n",
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'count': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'lives': [{'province': '广东',\n",
       "   'city': '从化区',\n",
       "   'adcode': '440117',\n",
       "   'weather': '多云',\n",
       "   'temperature': '21',\n",
       "   'winddirection': '东',\n",
       "   'windpower': '≤3',\n",
       "   'humidity': '96',\n",
       "   'reporttime': '2020-11-16 20:22:36'}]}"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 输入提示\n",
    "* 1、url：https://restapi.amap.com/v3/assistant/inputtips?parameters\n",
    "* 2、requests.get()\n",
    "* 3、参数  \n",
    "    A.必选：key，keywords  \n",
    "    B.可选：type，location，city，citylimit（默认值false），datatype（默认值all）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {},
   "outputs": [],
   "source": [
    "#数据准备\n",
    "s_keywords = \"麦当劳\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = \"https://restapi.amap.com/v3/assistant/inputtips?parameters\"\n",
    "params = {\n",
    "    \"key\":chen_key,\n",
    "    \"keywords\":s_keywords\n",
    "}\n",
    "r = requests.get(url,params)\n",
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'count': '10',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'tips': [{'id': 'B036706ZVC',\n",
       "   'name': '麦当劳(春城得来速店)',\n",
       "   'district': '云南省昆明市官渡区',\n",
       "   'adcode': '530111',\n",
       "   'location': '102.726178,25.018438',\n",
       "   'address': '春城路166-168号上海沙龙首层',\n",
       "   'typecode': '050302',\n",
       "   'city': []},\n",
       "  {'id': 'B001C7XFZZ',\n",
       "   'name': '麦当劳(郫都区店)',\n",
       "   'district': '四川省成都市金牛区',\n",
       "   'adcode': '510106',\n",
       "   'location': '103.978189,30.724212',\n",
       "   'address': '蜀西路399号',\n",
       "   'typecode': '050300',\n",
       "   'city': []},\n",
       "  {'id': 'B001C806EK',\n",
       "   'name': '麦当劳(欢乐谷店)',\n",
       "   'district': '四川省成都市金牛区',\n",
       "   'adcode': '510106',\n",
       "   'location': '104.035489,30.719447',\n",
       "   'address': '沙西线1号华侨城公园广场',\n",
       "   'typecode': '050302',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFF6RH4F',\n",
       "   'name': '麦当劳(地铁中心城店)',\n",
       "   'district': '四川省成都市青羊区',\n",
       "   'adcode': '510105',\n",
       "   'location': '104.065310,30.657614',\n",
       "   'address': '天府广场B1层',\n",
       "   'typecode': '050302',\n",
       "   'city': []},\n",
       "  {'id': 'B001C8059O',\n",
       "   'name': '麦当劳(软件园DT餐厅)',\n",
       "   'district': '四川省成都市武侯区',\n",
       "   'adcode': '510107',\n",
       "   'location': '104.070686,30.542893',\n",
       "   'address': '天府大道中段801号,天府软件园B区',\n",
       "   'typecode': '050302',\n",
       "   'city': []},\n",
       "  {'id': 'B001C80DKS',\n",
       "   'name': '麦当劳(五桂桥餐厅)',\n",
       "   'district': '四川省成都市成华区',\n",
       "   'adcode': '510108',\n",
       "   'location': '104.128358,30.636119',\n",
       "   'address': '迎晖路194号五桂桥客运站内',\n",
       "   'typecode': '050302',\n",
       "   'city': []},\n",
       "  {'id': 'B001C8OFKY',\n",
       "   'name': '麦当劳(成都东站)',\n",
       "   'district': '四川省成都市成华区',\n",
       "   'adcode': '510108',\n",
       "   'location': '104.143451,30.628907',\n",
       "   'address': '青衣江路成都东站候车大厅2层',\n",
       "   'typecode': '050302',\n",
       "   'city': []},\n",
       "  {'id': 'B001786OHS',\n",
       "   'name': '麦当劳(鲁能星城得来速店)',\n",
       "   'district': '重庆市渝北区',\n",
       "   'adcode': '500112',\n",
       "   'location': '106.560443,29.594875',\n",
       "   'address': '渝鲁大道666号鲁能新城7街区1层',\n",
       "   'typecode': '050302',\n",
       "   'city': []},\n",
       "  {'id': 'B001D0YL8Z',\n",
       "   'name': '麦当劳(北客站北店)',\n",
       "   'district': '陕西省西安市未央区',\n",
       "   'adcode': '610112',\n",
       "   'location': '108.938634,34.378386',\n",
       "   'address': '文景路北口西安北站F3层',\n",
       "   'typecode': '050302',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFF657F1',\n",
       "   'name': '麦当劳(金莎国际店)',\n",
       "   'district': '陕西省西安市雁塔区',\n",
       "   'adcode': '610113',\n",
       "   'location': '108.947617,34.225757',\n",
       "   'address': '长安中路65号金莎国际广场一层',\n",
       "   'typecode': '050302',\n",
       "   'city': []}]}"
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "165px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
